lib/parser.js
/**
   * parse a openapi specification
   * @param {string|object} specification Filename of JSON/YAML file or object containing an openapi specification
   * @returns {object} fastify configuration information
   */
parse a openapi specification
@param {string|object} specification Filename of JSON/YAML file or object containing an openapi specification
@returns {object} fastify configuration information
parse a openapi specification @param { string|object } specification Filename of JSON / YAML file or object containing an openapi specification @returns { object } fastify configuration information
async parse(specification) {
    let spec, data;
    try {
      data = await swp.parse(specification);
      this.original = JSON.parse(JSON.stringify(data, null, 2));
      spec = await swp.validate(data);
    } catch (e) {
      console.log(e.message);
      spec = {};
    }
    if (spec.swagger && spec.swagger.indexOf("2.0") === 0) {
      const parserV2 = new ParserV2();
      return parserV2.parse(spec);
    } else if (spec.openapi && spec.openapi.indexOf("3.0") === 0) {
      const parserV3 = new ParserV3();
      return parserV3.parse(spec);
    } else {
      throw new Error(
        "'specification' parameter must contain a valid version 2.0 or 3.0.x specification"
      );
    }
  }
async parse ( specification ) { let spec , data ; try { data = await swp . parse ( specification ) ; this . original = JSON . parse ( JSON . stringify ( data , null , 2 ) ) ; spec = await swp . validate ( data ) ; } catch ( e ) { console . log ( e . message ) ; spec = { } ; } if ( spec . swagger && spec . swagger . indexOf ( "2.0" ) === 0 ) { const parserV2 = new ParserV2 ( ) ; return parserV2 . parse ( spec ) ; } else if ( spec . openapi && spec . openapi . indexOf ( "3.0" ) === 0 ) { const parserV3 = new ParserV3 ( ) ; return parserV3 . parse ( spec ) ; } else { throw new Error ( "'specification' parameter must contain a valid version 2.0 or 3.0.x specification" ) ; } }
parse a openapi specification
 @param {string|object} specification Filename of JSON/YAML file or object containing an openapi specification
 @returns {object} fastify configuration information
parse a openapi specification @param { string|object } specification Filename of JSON / YAML file or object containing an openapi specification @returns { object } fastify configuration information
// parse first, to avoid dereferencing of $ref's // save the original (with $refs) because swp.validate modifies its input // and validate // eslint-disable-next-line