bin/swagger-jsdoc.js
function createSpecification(swaggerDefinition, apis, fileName) {
  // Options for the swagger docs
  const options = {
    // Import swaggerDefinitions
    swaggerDefinition,
    // Path to the API docs
    apis,
  };

  // Initialize swagger-jsdoc -> returns validated JSON or YAML swagger spec
  let swaggerSpec;
  const ext = path.extname(fileName);

  if (ext === '.yml' || ext === '.yaml') {
    swaggerSpec = jsYaml.dump(swaggerJSDoc(options), {
      schema: jsYaml.JSON_SCHEMA,
      noRefs: true,
    });
  } else {
    swaggerSpec = JSON.stringify(swaggerJSDoc(options), null, 2);
  }

  fs.writeFile(fileName, swaggerSpec, err => {
    if (err) {
      throw err;
    }
    console.log('Swagger specification is ready.');
  });
}
function createSpecification(swaggerDefinition, apis, fileName) {
  // Options for the swagger docs
  const options = {
    // Import swaggerDefinitions
    swaggerDefinition,
    // Path to the API docs
    apis,
  };

  // Initialize swagger-jsdoc -> returns validated JSON or YAML swagger spec
  let swaggerSpec;
  const ext = path.extname(fileName);

  if (ext === '.yml' || ext === '.yaml') {
    swaggerSpec = jsYaml.dump(swaggerJSDoc(options), {
      schema: jsYaml.JSON_SCHEMA,
      noRefs: true,
    });
  } else {
    swaggerSpec = JSON.stringify(swaggerJSDoc(options), null, 2);
  }

  fs.writeFile(fileName, swaggerSpec, err => {
    if (err) {
      throw err;
    }
    console.log('Swagger specification is ready.');
  });
}
function createSpecification ( swaggerDefinition , apis , fileName ) { // Options for the swagger docs const options = { // Import swaggerDefinitions swaggerDefinition , // Path to the API docs apis , } ; // Initialize swagger-jsdoc -> returns validated JSON or YAML swagger spec let swaggerSpec ; const ext = path . extname ( fileName ) ; if ( ext === '.yml' || ext === '.yaml' ) { swaggerSpec = jsYaml . dump ( swaggerJSDoc ( options ) , { schema : jsYaml . JSON_SCHEMA , noRefs : true , } ) ; } else { swaggerSpec = JSON . stringify ( swaggerJSDoc ( options ) , null , 2 ) ; } fs . writeFile ( fileName , swaggerSpec , err => { if ( err ) { throw err ; } console . log ( 'Swagger specification is ready.' ) ; } ) ; }
Creates a swagger specification from a definition and a set of files.
@function
@param {object} swaggerDefinition - The swagger definition object.
@param {array} apis - List of files to extract documentation from.
@param {string} fileName - Name the output file.
Creates a swagger specification from a definition and a set of files .