UNPKG

reqover

Version:

Reqover is language agnostic tool that gives a picture about coverage of APIs based on Open API (Swagger).

52 lines (43 loc) 1.52 kB
const { getSwaggerPaths, getSwaggerCoverageReport, } = require("./swagger.service"); const path = require("path"); const { readResults, saveReport } = require("./results.service"); const createCoverageReport = async ( swaggerFilePath, resultsFolderPath, options ) => { const baseApiPath = options.baseApiPath; console.log("Start coverage report generation!"); console.log("Swagger file: " + swaggerFilePath); console.log("Data folder: " + resultsFolderPath); const ignoreConfig = options?.ignore; const includeOptionalParams = options?.includeOptionalParams; const enableDebug = options.enableDebug; if (baseApiPath) { console.log("Base API path: " + baseApiPath); } if (enableDebug) { console.log("Ignore config: \n" + JSON.stringify(ignoreConfig, null, 2)); } const swaggerApiList = await getSwaggerPaths(baseApiPath, swaggerFilePath); const swagger_results = await readResults(resultsFolderPath); const report = await getSwaggerCoverageReport({ swaggerApiList: swaggerApiList, swagger_results: swagger_results, ignoreConfig: ignoreConfig, enableDebug: enableDebug, includeOptionalParams: includeOptionalParams }); const reportPath = options.reportFolder; const reportName = "coverage.json"; const reportDestination = path.join(reportPath, reportName); saveReport(reportPath, report, reportName); console.log("Coverage report saved to " + reportDestination); return reportDestination; }; module.exports = { createCoverageReport, };