parent
6319572a55
commit
84e9486062
|
@ -124,7 +124,9 @@ var routeHelper = module.exports = {
|
|||
|
||||
var apiDoc = {
|
||||
path: routeHelper.convertPathFragments(route.path),
|
||||
operations: [{
|
||||
// Create the operation doc. Use `extendWithType` to add the necessary
|
||||
// `items` and `format` fields.
|
||||
operations: [routeHelper.extendWithType({
|
||||
method: routeHelper.convertVerb(route.verb),
|
||||
// [rfeng] Swagger UI doesn't escape '.' for jQuery selector
|
||||
nickname: route.method.replace(/\./g, '_'),
|
||||
|
@ -137,10 +139,10 @@ var routeHelper = module.exports = {
|
|||
responseMessages: [],
|
||||
summary: route.description, // TODO(schoon) - Excerpt?
|
||||
notes: '' // TODO(schoon) - `description` metadata?
|
||||
}]
|
||||
})]
|
||||
};
|
||||
// Convert types and return.
|
||||
return routeHelper.extendWithType(apiDoc);
|
||||
|
||||
return apiDoc;
|
||||
},
|
||||
|
||||
convertPathFragments: function convertPathFragments(path) {
|
||||
|
|
|
@ -53,6 +53,28 @@ describe('route-helper', function() {
|
|||
expect(paramDoc.format).to.equal('byte');
|
||||
});
|
||||
|
||||
it('correctly converts return types (arrays)', function() {
|
||||
var doc = createAPIDoc({
|
||||
returns: [
|
||||
{arg: 'data', type: ['customType']}
|
||||
]
|
||||
});
|
||||
var opDoc = doc.operations[0];
|
||||
expect(opDoc.type).to.equal('array');
|
||||
expect(opDoc.items).to.eql({type: 'customType'});
|
||||
});
|
||||
|
||||
it('correctly converts return types (format)', function() {
|
||||
var doc = createAPIDoc({
|
||||
returns: [
|
||||
{arg: 'data', type: 'buffer'}
|
||||
]
|
||||
});
|
||||
var opDoc = doc.operations[0];
|
||||
expect(opDoc.type).to.equal('string');
|
||||
expect(opDoc.format).to.equal('byte');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Easy wrapper around createRoute
|
||||
|
|
Loading…
Reference in New Issue