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

Package detail

oas-resolver

Mermade4.3mBSD-3-Clause2.5.6

Resolve external $refs in OpenAPI (swagger) 2.0 / 3.x definitions

openapi, swagger, oas, resolver, resolution, ref, json-pointer, json-ref

readme

oas-resolver

Usage

const yaml = require('yaml');
const input = yaml.parse(str);
const source = url; // or filename
resolver.resolve(input,source,options)
.then(function(options){
  fs.writeFileSync(outputFile,yaml.stringify(options.openapi),'utf8');
})
.catch(function(ex){
  // ...
});

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.