Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/mashery/iodocs into add-j…

…son-schema-validation

Conflicts:
	app.js - resolved by keeping my version of adding content to the request, as I want
                  the ability to have query parameters _and_ request content.
  • Loading branch information...
commit 097463a92bc9648c6130bba526bcc7a880c1b009 2 parents b64c7c6 + 7ac39c7
@dgc-wh dgc-wh authored
Showing with 58 additions and 19 deletions.
  1. +9 −2 README.md
  2. +20 −16 app.js
  3. +22 −0 public/stylesheets/style.css
  4. +7 −1 views/api.jade
View
11 README.md
@@ -379,6 +379,11 @@ You should look at the *./public/data/* directory for examples.
"sugarbombs",
"frostedteeth"
],
+ "EnumeratedDescription": {
+ "fruitscoops": "Fruit Scoops (packed with fruit goodness)",
+ "sugarbombs": "Sugar Bombs (filled with sugar)",
+ "frostedteeth": "Frosted Teeth (sugar coating)"
+ },
"Description":"The type of cereal desired"
},
{
@@ -425,9 +430,11 @@ Line:
24. "EnumeratedList" key value is an array of enumerated values that will render a drop-down (select box) on the form.
-25. Each value in the list is a string.
+25. "EnumeratedDescription" key value is an object of enumerated values as keys, and their descriptions as values that will be displayed below the Description.
-35. "Type" key value is *boolean* that will render a drop-down (select box) on the form for *true* and *false*.
+26. Each value in the list is a string.
+
+27. "Type" key value is *boolean* that will render a drop-down (select box) on the form for *true* and *false*.
SUPPORT
=======
View
36 app.js
@@ -357,7 +357,7 @@ function processRequest(req, res, next) {
host: baseHostUrl,
port: baseHostPort,
method: httpMethod,
- path: apiConfig.publicPath + methodURL + ((paramString.length > 0) ? '?' + paramString : "")
+ path: apiConfig.publicPath + methodURL// + ((paramString.length > 0) ? '?' + paramString : "")
};
if (apiConfig.oauth) {
@@ -510,6 +510,10 @@ function processRequest(req, res, next) {
function unsecuredCall() {
console.log('Unsecured Call');
+ if (['POST','PUT','DELETE'].indexOf(httpMethod) === -1) {
+ options.path += ((paramString.length > 0) ? '?' + paramString : "");
+ }
+
// Add API Key to params, if any.
if (apiKey != '' && apiKey != 'undefined' && apiKey != undefined) {
if (options.path.indexOf('?') !== -1) {
@@ -556,9 +560,6 @@ function processRequest(req, res, next) {
options.headers = headers;
}
- if (!options.headers['Content-Length']) {
- options.headers['Content-Length'] = 0;
- }
if (config.debug) {
console.log(util.inspect(options));
@@ -583,6 +584,7 @@ function processRequest(req, res, next) {
// API Call. response is the response from the API, res is the response we will send back to the user.
var apiCall = doRequest(options, function(response) {
response.setEncoding('utf-8');
+
if (config.debug) {
console.log('HEADERS: ' + JSON.stringify(response.headers));
console.log('STATUS CODE: ' + response.statusCode);
@@ -633,29 +635,30 @@ function processRequest(req, res, next) {
});
if(content !== ''){
- apiCall.write(content);
+ apiCall.write(content,'utf-8');
}
apiCall.end();
}
}
+
// Dynamic Helpers
// Passes variables to the view
app.dynamicHelpers({
session: function(req, res) {
// If api wasn't passed in as a parameter, check the path to see if it's there
- if (!req.params.api) {
- pathName = req.url.replace('/','');
- // Is it a valid API - if there's a config file we can assume so
- fs.stat('public/data/' + pathName + '.json', function (error, stats) {
- if (stats) {
- req.params.api = pathName;
- }
- });
- }
- // If the cookie says we're authed for this particular API, set the session to authed as well
+ if (!req.params.api) {
+ pathName = req.url.replace('/','');
+ // Is it a valid API - if there's a config file we can assume so
+ fs.stat('public/data/' + pathName + '.json', function (error, stats) {
+ if (stats) {
+ req.params.api = pathName;
+ }
+ });
+ }
+ // If the cookie says we're authed for this particular API, set the session to authed as well
if (req.params.api && req.session[req.params.api] && req.session[req.params.api]['authed']) {
- req.session['authed'] = true;
+ req.session['authed'] = true;
}
return req.session;
@@ -680,6 +683,7 @@ app.dynamicHelpers({
}
})
+
//
// Routes
//
View
22 public/stylesheets/style.css
@@ -737,6 +737,28 @@ li {
zoom: 1;
}
+dl {
+ display: block;
+ margin-bottom: 10px;
+ font-weight: normal;
+}
+dt {
+ width: 30%;
+ border-top: 1px rgba(0,0,0,.2) solid;
+ padding-top: 5px;
+ margin-top: 5px;
+ display: block;
+ float: left;
+}
+dd {
+ width: 70%;
+ border-top: 1px rgba(0,0,0,.2) solid;
+ padding-top: 5px;
+ margin-top: 5px;
+ display: block;
+ float: left;
+}
+
@media print {
* {
background: transparent !important;
View
8 views/api.jade
@@ -120,7 +120,13 @@ ul
- else
input(name='params[' + parameter.Name + ']', value=parameter.Default, placeholder=className)
td.type=parameter.Type
- td.description=parameter.Description || 'No description'
+ td.description
+ p=parameter.Description || 'No description'
+ - if (parameter.Type =='enumerated' && parameter.EnumeratedDescription)
+ dl.clearfix
+ - each description, choice in parameter.EnumeratedDescription
+ dt #{choice}
+ dd #{description}
- if (method.headers && method.headers.length > 0)
div.headers
h4.title
Please sign in to comment.
Something went wrong with that request. Please try again.