How to use the swagger2openapi/validate.js.validateSync function in swagger2openapi

To help you get started, we’ve selected a few swagger2openapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github temando / serverless-openapi-documentation / src / DocumentGenerator.ts View on Github external
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');
    }
  }
github LucyBot-Inc / api-spec-converter / lib / formats / openapi_3.js View on Github external
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);