function loadDefinition(defPath, swaggerDefinition) {
  const resolvedPath = path.resolve(defPath);
  const extName = path.extname(resolvedPath);

  // eslint-disable-next-line
  const loadJs = () => require(resolvedPath);
  const loadJson = () => JSON.parse(swaggerDefinition);
  // eslint-disable-next-line
  const loadYaml = () => require('yaml').parse(swaggerDefinition);

  const LOADERS = {
    '.js': loadJs,
    '.json': loadJson,
    '.yml': loadYaml,
    '.yaml': loadYaml,
  };

  const loader = LOADERS[extName];

  if (loader === undefined) {
    throw new Error('Definition file should be .js, .json, .yml or .yaml');
  }

  return loader();
}
/**
 * Get an object of the definition file configuration.
 * @param {string} defPath
 * @param {object} swaggerDefinition
 */
Get an object of the definition file configuration.
@param {string} defPath
@param {object} swaggerDefinition
Get an object of the definition file configuration . @param { string } defPath @param { object } swaggerDefinition
function loadDefinition(defPath, swaggerDefinition) {
  const resolvedPath = path.resolve(defPath);
  const extName = path.extname(resolvedPath);
  const loadJs = () => require(resolvedPath);
  const loadJson = () => JSON.parse(swaggerDefinition);
  const loadYaml = () => require('yaml').parse(swaggerDefinition);
  const LOADERS = {
    '.js': loadJs,
    '.json': loadJson,
    '.yml': loadYaml,
    '.yaml': loadYaml,
  };
  const loader = LOADERS[extName];
  if (loader === undefined) {
    throw new Error('Definition file should be .js, .json, .yml or .yaml');
  }
  return loader();
}
function loadDefinition ( defPath , swaggerDefinition ) { const resolvedPath = path . resolve ( defPath ) ; const extName = path . extname ( resolvedPath ) ; const loadJs = ( ) => require ( resolvedPath ) ; const loadJson = ( ) => JSON . parse ( swaggerDefinition ) ; const loadYaml = ( ) => require ( 'yaml' ) . parse ( swaggerDefinition ) ; const LOADERS = { '.js' : loadJs , '.json' : loadJson , '.yml' : loadYaml , '.yaml' : loadYaml , } ; const loader = LOADERS [ extName ] ; if ( loader === undefined ) { throw new Error ( 'Definition file should be .js, .json, .yml or .yaml' ) ; } return loader ( ) ; }
Get an object of the definition file configuration.
Get an object of the definition file configuration .
// eslint-disable-next-line // eslint-disable-next-line