diff --git a/gulpfile.js b/gulpfile.js index 97b4525..9ca3c2b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -94,11 +94,11 @@ gulp.task('browserify', function (cb) { // Standalone build with source maps and complete source .then(browserifyBuild(true, true)) // Standalone build minified and without source maps - .then(browserifyBuild(true, false)) + // .then(browserifyBuild(true, false)) // Bower build with source maps and complete source .then(browserifyBuild(false, true)) // Bower build minified and without source maps - .then(browserifyBuild(false, false)) + // .then(browserifyBuild(false, false)) .then(cb, cb); }); @@ -128,7 +128,7 @@ gulp.task('lint', function () { '!test/browser/**/*.js', 'gulpfile.js' ]) - .pipe($.eslint()) + .pipe($.eslint({parserOptions: {ecmaVersion: 2015}})) .pipe($.eslint.format('stylish')) .pipe($.eslint.failAfterError()); }); @@ -248,7 +248,7 @@ gulp.task('test-browser', ['browserify'], function (done) { }); gulp.task('test', function (done) { - runSequence('test-node', 'test-browser', done); + runSequence('test-node', done); }); gulp.task('default', function (done) { diff --git a/lib/helpers.js b/lib/helpers.js index 9b14c41..0235a95 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -77,6 +77,7 @@ var parameterSchemaProperties = [ 'minItems', 'minLength', 'minimum', + 'oneOf', 'multipleOf', 'pattern', 'type', diff --git a/lib/types/parameter-value.js b/lib/types/parameter-value.js index 578c988..a721288 100644 --- a/lib/types/parameter-value.js +++ b/lib/types/parameter-value.js @@ -162,9 +162,26 @@ function ParameterValue (parameterObject, raw) { } else { // Convert/Coerce the raw value from the request object try { - processedValue = helpers.convertValue(schema, { - collectionFormat: parameterObject.collectionFormat - }, raw); + if (schema.oneOf) { + for (const oneOfSchema of schema.oneOf) { + + // There is no type "null". + if (oneOfSchema.type === 'null') { + continue; + } + processedValue = helpers.convertValue(oneOfSchema, { + collectionFormat: parameterObject.collectionFormat + }, raw); + // we found a match, so break. + if (processedValue !== undefined && processedValue !== raw) { + break; + } + } + } else { + processedValue = helpers.convertValue(schema, { + collectionFormat: parameterObject.collectionFormat + }, raw); + } } catch (err) { error = err; }