Corrected handling of type for operation, including containers

This commit is contained in:
Shelby Sanders 2015-01-09 21:53:37 -08:00
parent 5fcc411c06
commit 3bd1e4440d
1 changed files with 18 additions and 1 deletions

View File

@ -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;
}
};