Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

oas-validator

Mermade4.3mBSD-3-Clause5.0.8

Parser/validator for OpenAPI 3.x definitions

openapi, oas, parser, validator, validation

readme

oas-validator

Usage:

const validator = require('oas-validator');
const options = {};
validator.validate(openapi, options)
.then(function(options){
  // options.valid contains the result of the validation, true in this branch
})
.catch(function(err){
  console.warn(err.message);
  if (options.context) console.warn('Location',options.context.pop());
});

If a third callback argument to validate is provided, the callback will be called instead of a Promise being returned.

oas-validator is an assertion-based validator, which stops on the first error, as structural errors may otherwise cause further (spurious) errors to be reported. If the lint option is set, multiple warnings may be reported.

See here for complete documentation of the options object.

changelog

Change Log

swagger2openapi v7.0 and oas-validator v5.0

  • remove use of ajv for fallback schema validation

swagger2openapi v6.1.0 and oas-resolver v2.4.0

New properties on the options object:

  • fetch - to override the built-in fetch function
  • fetchOptions - additional options to be passed to the fetch function

swagger2openapi v6.0.0 and oas-validator v4.0.0

  • Converter will now error out if passed in input containing YAML anchors/aliases. To bypass this check, pass the --anchors option or set options.anchors to true.
  • Validator method validateSync has now been renamed validateInner as it (still) returns a Promise or calls a given callback.