All files / src/util openApi.ts

83.33% Statements 5/6
0% Branches 0/2
100% Functions 1/1
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14    45x 208x 208x   208x              
import { OpenAPIV3 } from 'express-openapi-validator/dist/framework/types';
 
export const versionPathFromSpec = (specPath: string) => {
  try {
    const apiDoc = require(specPath) as OpenAPIV3.Document;
 
    return `/v${apiDoc.info.version}`;
  } catch (error) {
    throw new Error(
      `Reading version from '${specPath}' due to\n${error instanceof Error ? error.stack : JSON.stringify(error)}\n`
    );
  }
};