Skip to content

Commit

Permalink
fix the failure to parse req.swagger.query
Browse files Browse the repository at this point in the history
  • Loading branch information
lanchongyizu committed May 14, 2018
1 parent a01e8a0 commit 39712e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/services/swagger-api-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ function swaggerFactory(
function _parseQuery(req) {
req.swagger.query = _(req.swagger.params)
.pick(function(param) {
if (param.parameterObject) {
return param.parameterObject.in === 'query' &&
if (param.schema) {
return param.schema.in === 'query' &&
param.value !== undefined;
}
return false;
})
.mapValues(function(param) {
req.query = _(req.query).omit(param.parameterObject.definition.name).value();
req.query = _(req.query).omit(param.schema.name).value();
return param.value;
}).value();
}
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/services/swagger-api-service-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,31 @@ describe('Services.Http.Swagger', function() {
sort: {
},
firstName: {
parameterObject: {
schema: {
in: 'query',
type: 'string',
definition: { name: 'firstName' }
name: 'firstName'
},
value: 'Rack'
},
lastName: {
parameterObject: {
schema: {
in: 'query',
type: 'string',
definition: { name: 'lastName' }
name: 'lastName'
},
value: 'HD'
},
undefinedName: {
parameterObject: {
schema: {
in: 'query',
type: 'string',
definition: { name: 'undefinedName' }
name: 'undefinedName'
},
value: undefined
},
inBody: {
parameterObject: {
schema: {
in: 'body',
type: 'string',
},
Expand Down

0 comments on commit 39712e4

Please sign in to comment.