Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it(swagger + ' should be semantically valid.', function (done) {
oav.validateSpec(swagger, {consoleLogLevel: 'error'}).then(function (validationResult) {
//console.dir(validationResult, {depth: null, colors: true});
done(assert(validationResult.validateSpec && validationResult.validateSpec.errors && validationResult.validateSpec.errors.length === 0,
`swagger "${swagger}" contains semantic validation errors.`));
}).catch(function (err) {
console.dir(err, {depth: null, colors: true});
done(err);
});
});
}).value();
it(swagger + ' should have valid examples.', function (done) {
oav.validateExamples(swagger, null, {consoleLogLevel: 'error'}).then(function (validationResult) {
//console.dir(validationResult, {depth: null, colors: true});
done(assert(validationResult.validityStatus === true, `swagger "${swagger}" contains model validation errors.`));
}).catch(function (err) {
console.dir(err, {depth: null, colors: true});
done(err);
});
});
}).value();
function runSemanticValidator(swagger) {
console.log('\t- Running Semantic Validator.')
return oav.validateSpec(swagger, {consoleLogLevel: 'off'}).then(function (validationResult) {
//console.dir(validationResult, { depth: null, colors: true });
return validationResult.validateSpec.errors;
}).catch(function (err) {
console.dir(err, { depth: null, colors: true });
});
}