Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public generate () {
const result: any = {};
process.stdout.write(`${ c.bold.yellow('[VALIDATION]') } Validating OpenAPI generated output\n`);
try {
openApiValidator.validateSync(this.config, result);
process.stdout.write(`${ c.bold.green('[VALIDATION]') } OpenAPI valid: ${c.bold.green('true')}\n\n`);
return this.config;
} catch (e) {
process.stdout.write(
`${c.bold.red('[VALIDATION]')} Failed to validate OpenAPI document: \n\n${c.yellow(e.message)}\n\n` +
`${c.bold.green('Path:')} ${result.context.pop()}\n`,
);
throw new Error('Failed to validate OpenAPI document');
}
}
var promise = new Promise(function(resolve,reject){
var result = {};
try {
result = validator.validateSync(openapi,result,function(err,options){
});
}
catch (ex) {
result.errors = {message: ex.message, context: result.context};
}
resolve(result);
});
return Promise.resolve(promise).asCallback(callback);