зеркало из https://github.com/Azure/sway.git
Support OneOf for parameter validation (#24)
* Support OneOf for parameter validation * disable browserify build without source maps as it fails
This commit is contained in:
Родитель
a66e2f23fd
Коммит
21d2160311
|
@ -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) {
|
||||
|
|
|
@ -77,6 +77,7 @@ var parameterSchemaProperties = [
|
|||
'minItems',
|
||||
'minLength',
|
||||
'minimum',
|
||||
'oneOf',
|
||||
'multipleOf',
|
||||
'pattern',
|
||||
'type',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче