Skip to content

Commit dd5a1f6

Browse files
author
kavaliero
committed
add example file
1 parent f269117 commit dd5a1f6

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

example/yoda.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
({
2+
auth:function(){return auth({provider:fs('/bin/yoda')})},
3+
/**
4+
* @category All
5+
* @param {string} [sentence] Input sentence to turn into Yoda-speak
6+
* @methodhttp GET
7+
*/
8+
'YodaSpeak': function(args, opts) {
9+
var url = 'https://yoda.p.mashape.com/yoda'
10+
args = args || {}
11+
if (args['sentence'] == null) throw new Error('sentence is a required parameter')
12+
var rgx = new RegExp('\{sentence\}', 'g')
13+
if (url.match(rgx)) {
14+
url = url.replace(rgx, args['sentence'])
15+
if (args['sentence']) delete args['sentence']
16+
}
17+
if (url.indexOf('[/sentence]') !== -1) {
18+
url = url.replace('[/sentence]', '/' + args['sentence'])
19+
if (args['sentence']) delete args['sentence']
20+
}
21+
if (url.indexOf('[/sentence]') !== -1) url = url.replace('[/sentence]', '')
22+
return http({provider:fs('/bin/yoda'),url:url,method:'GET',params:args}, opts)
23+
}
24+
})

example/yoda.wadl

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4+
xmlns:apigee="http://api.apigee.com/wadl/2010/07/"
5+
xmlns="http://wadl.dev.java.net/2009/02" xmlns:t="urn:github:githubresponse"
6+
xmlns:webshell="http://webshell.io/wadl/2012/06/"
7+
xsi:schemaLocation="http://wadl.dev.java.net/2009/02 http://apigee.com/schemas/wadl-schema.xsd http://api.apigee.com/wadl/2010/07/ http://apigee.com/schemas/apigee-wadl-extensions.xsd http://webshell.io/wadl/2012/06/ http://webshell.io/wadl/webshell-extensions.xsd">
8+
<resources base="https://yoda.p.mashape.com">
9+
<resource path="/yoda">
10+
<method id="YodaSpeak" name="GET">
11+
<apigee:tags>
12+
<apigee:tag primary="true">All</apigee:tag>
13+
</apigee:tags>
14+
<webshell:authentication required="true"/>
15+
<doc></doc>
16+
<request>
17+
<param name="sentence" required="true" type="string" style="query">
18+
<doc>
19+
Input sentence to turn into Yoda-speak</doc>
20+
</param>
21+
</request>
22+
</method>
23+
</resource>
24+
</resources>
25+
</application>

pages/add-your-api.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ <h2>Wrapper in Javascript</h2>
4343
<section id="generate-from-wadl">
4444
<h2>Generate from WADL</h2>
4545
<p>WADL is a standard for describing REST API using a XML file. We've made a builtin which generate javascript compatible with Webshell from a WADL File</p>
46+
<a href="https://webshell.github.io/docs/example/yoda.wadl"></a>
4647
<pre class="prettyprint">wadl({
4748
xml: fs.username.path['wadl.xml'],
4849
target: fs.username.apiName
@@ -52,11 +53,12 @@ <h2>Generate from WADL</h2>
5253
<p>As the documentation of the API is contained in the WADL File, we generate HTML files to make a pretty and simple docs. To read documentation, use <code>docs()</code> builtin function</p>
5354
<p> At the end we have a js file and a docs directory with all the HTML file : </p>
5455
<img src="http://webshell.github.io/docs/images/webshell-wadl.png" />
56+
<a href="https://webshell.github.io/docs/example/yoda.js"></a>
5557
</section>
5658
<section id="generate-from-mashape">
5759
<h2>Generate from Mashape XML File</h2>
5860
<p>Mashape is an API Hub with an API to access their API description. This XML is based on any standard but was made nicely. Authentication information is available in the XML so, we generate for you the configuration file (conf.json)</p>
59-
<p>The mashape builtin generate a wadl file, then we call the wadl builtin to general all the js and documentation for the api </p>
61+
<p>The mashape builtin generate a wadl file, then we call the wadl builtin to generate all the js and documentation for the api </p>
6062
<pre class="prettyprint">mashape({
6163
xml: fs.username.path['mashape-api.xml'],
6264
output: fs.username.apiName

0 commit comments

Comments
 (0)