Add support for `context` and `res` param types

This commit is contained in:
Krishna Raman 2014-10-13 18:57:39 -07:00
parent d1084950a9
commit 856d34b9d4
2 changed files with 40 additions and 1 deletions

View File

@ -61,7 +61,12 @@ var routeHelper = module.exports = {
if (typeof arg.http === 'function') return false;
// Don't show arguments set to the incoming http request.
// Please note that body needs to be shown, such as User.create().
if (arg.http.source === 'req') return false;
if (arg.http.source === 'req' ||
arg.http.source === 'res' ||
arg.http.source === 'context') {
return false;
}
return true;
});

View File

@ -109,6 +109,40 @@ describe('route-helper', function() {
});
expect(doc.operations[0].parameters[0].description).to.equal('line1\nline2');
});
it('correctly does not include context params', function() {
var doc = createAPIDoc({
accepts: [
{arg: 'ctx', http: {source: 'context'}}
],
path: '/test'
});
var params = doc.operations[0].parameters;
expect(params.length).to.equal(0);
});
it('correctly does not include request params', function() {
var doc = createAPIDoc({
accepts: [
{arg: 'req', http: {source: 'req'}}
],
path: '/test'
});
var params = doc.operations[0].parameters;
expect(params.length).to.equal(0);
});
it('correctly does not include response params', function() {
var doc = createAPIDoc({
accepts: [
{arg: 'res', http: {source: 'res'}}
],
path: '/test'
});
var params = doc.operations[0].parameters;
expect(params.length).to.equal(0);
});
});
// Easy wrapper around createRoute