How to use ibm-openapi-validator - 1 common examples

To help you get started, we’ve selected a few ibm-openapi-validator 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 contiamo / restful-react / src / scripts / import-open-api.ts View on Github external
const validate = async (specs: OpenAPIObject) => {
  // tslint:disable:no-console
  const log = console.log;

  // Catch the internal console.log to add some information if needed
  // because openApiValidator() calls console.log internally and
  // we want to add more context if it's used
  let wasConsoleLogCalledFromBlackBox = false;
  console.log = (...props: any) => {
    wasConsoleLogCalledFromBlackBox = true;
    log(...props);
  };
  const { errors, warnings } = await openApiValidator(specs);
  console.log = log; // reset console.log because we're done with the black box

  if (wasConsoleLogCalledFromBlackBox) {
    log("More information: https://github.com/IBM/openapi-validator/#configuration");
  }
  if (warnings.length) {
    log(chalk.yellow("(!) Warnings"));
    warnings.forEach(i =>
      log(
        chalk.yellow(`
Message : ${i.message}
Path    : ${i.path}`),
      ),
    );
  }
  if (errors.length) {

ibm-openapi-validator

Configurable and extensible validator/linter for OpenAPI documents

Apache-2.0
Latest version published 11 days ago

Package Health Score

78 / 100
Full package analysis

Popular ibm-openapi-validator functions

Similar packages