Skip to content

Commit

Permalink
Make code more readable. swagger-api#1006
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilson6 committed Apr 14, 2017
1 parent 217d430 commit 1e014a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ export function buildRequest({
const builder = parameterBuilders[parameter.in]
let value

if(parameter.in === 'body' && parameter.schema && parameter.schema.properties) {
//use the parameter value from the parameters object if it is set
if(parameter.name && parameters[parameter.name]) {
value = parameters[parameter.name];
} else if(parameter.in === 'body' && parameter.schema && parameter.schema.properties) {
//if this parameter is in the body and has an object schema, use the whole parameters object
value = parameters
}

value = (parameter && parameter.name && parameters[parameter.name]) || value

if (typeof parameter.default !== 'undefined' && typeof value === 'undefined') {
value = parameter.default
}
Expand Down
2 changes: 1 addition & 1 deletion test/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ describe('execute', () => {
})
})

it('should pass through the parameters object as the value if parameter is in the body', function () {
it('should use the whole parameters object as the parameter value if parameter is in the body', function () {
const spec = {
host: 'swagger.io',
paths: {
Expand Down

0 comments on commit 1e014a8

Please sign in to comment.