How to use the json-schema-ref-parser.YAML function in json-schema-ref-parser

To help you get started, we’ve selected a few json-schema-ref-parser 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 maxdome / swagger-combine / src / SwaggerCombine.js View on Github external
toString(format = this.opts.format) {
    if (String(format).toLowerCase() === 'yaml' || String(format).toLowerCase() === 'yml') {
      return $RefParser.YAML.stringify(this.combinedSchema);
    }

    return JSON.stringify(this.combinedSchema, null, 2);
  }
}
github APIDevTools / swagger-parser / lib / index.js View on Github external
module.exports = SwaggerParser;

/**
 * This class parses a Swagger 2.0 or 3.0 API, resolves its JSON references and their resolved values,
 * and provides methods for traversing, dereferencing, and validating the API.
 *
 * @constructor
 * @extends $RefParser
 */
function SwaggerParser () {
  $RefParser.apply(this, arguments);
}

util.inherits(SwaggerParser, $RefParser);
SwaggerParser.YAML = $RefParser.YAML;
SwaggerParser.parse = $RefParser.parse;
SwaggerParser.resolve = $RefParser.resolve;
SwaggerParser.bundle = $RefParser.bundle;
SwaggerParser.dereference = $RefParser.dereference;

/**
 * Alias {@link $RefParser#schema} as {@link SwaggerParser#api}
 */
Object.defineProperty(SwaggerParser.prototype, "api", {
  configurable: true,
  enumerable: true,
  get () {
    return this.schema;
  }
});