From 3bd1e4440d75fd4bad61e16bf33bb151376607d9 Mon Sep 17 00:00:00 2001 From: Shelby Sanders Date: Fri, 9 Jan 2015 21:53:37 -0800 Subject: [PATCH] Corrected handling of type for operation, including containers --- lib/route-helper.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/route-helper.js b/lib/route-helper.js index 941a480..8f73fb8 100644 --- a/lib/route-helper.js +++ b/lib/route-helper.js @@ -187,9 +187,10 @@ var routeHelper = module.exports = { // `items` and `format` fields. operations: [routeHelper.extendWithType({ method: routeHelper.convertVerb(route.verb), - deprecated: route.deprecated, // [rfeng] Swagger UI doesn't escape '.' for jQuery selector nickname: route.method.replace(/\./g, '_'), + deprecated: route.deprecated, + type: returns.model || returns.type || 'void', summary: route.description, // TODO(schoon) - Excerpt? notes: route.notes, // TODO(schoon) - `description` metadata? consumes: ['application/json', 'application/xml', 'text/xml'], @@ -295,6 +296,22 @@ var routeHelper = module.exports = { Object.keys(typeDesc).forEach(function(key){ obj[key] = typeDesc[key]; }); + + //Ensure brief properties are first + if (typeof obj === 'object') { + var keysToSink = ['authorizations', 'consumes', 'notes', 'produces', + 'parameters', 'responseMessages', 'summary']; + var outKeys = Object.keys(obj); + for (var outKeyIdx in outKeys) { + var outKey = outKeys[outKeyIdx]; + if (keysToSink.indexOf(outKey) != -1) { + var outValue = obj[outKey]; + delete obj[outKey]; + obj[outKey] = outValue; + } + } + } + return obj; } };