From 856d34b9d433fd20dd23bc5c9d37bf2c258eac20 Mon Sep 17 00:00:00 2001 From: Krishna Raman Date: Mon, 13 Oct 2014 18:57:39 -0700 Subject: [PATCH] Add support for `context` and `res` param types --- lib/route-helper.js | 7 ++++++- test/route-helper.test.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/route-helper.js b/lib/route-helper.js index 6cf5b4a..f52ed4c 100644 --- a/lib/route-helper.js +++ b/lib/route-helper.js @@ -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; }); diff --git a/test/route-helper.test.js b/test/route-helper.test.js index 52e21b8..6714480 100644 --- a/test/route-helper.test.js +++ b/test/route-helper.test.js @@ -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