From 1e014a8db70ffc0de3a8d84903d45a2261b472e9 Mon Sep 17 00:00:00 2001 From: Devin Wilson Date: Thu, 13 Apr 2017 21:47:11 -0600 Subject: [PATCH] Make code more readable. #1006 --- src/execute.js | 8 +++++--- test/execute.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/execute.js b/src/execute.js index 732fd408f..6a73c9478 100644 --- a/src/execute.js +++ b/src/execute.js @@ -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 } diff --git a/test/execute.js b/test/execute.js index 1915528e4..7804c8b17 100644 --- a/test/execute.js +++ b/test/execute.js @@ -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: {