Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auto-detect-newman.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ <h1>Swagger Coverage Report</h1>
&#128262; <!-- flashlight icon -->
</button>
<div class="meta-info">
<p><strong>Timestamp:</strong> 9/15/2025, 4:45:45 PM</p>
<p><strong>Timestamp:</strong> 9/16/2025, 5:47:53 PM</p>
<p><strong>API Spec:</strong> Test API</p>

<p><strong>Postman Collection:</strong> Test Newman Collection</p>
Expand Down
43 changes: 28 additions & 15 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { loadAndParseSpec, extractOperationsFromSpec } = require("./lib/swagger")
const { loadPostmanCollection, extractRequestsFromPostman } = require("./lib/postman");
const { loadNewmanReport, extractRequestsFromNewman } = require("./lib/newman");
const { matchOperationsDetailed } = require("./lib/match");
const { generateHtmlReport } = require("./lib/report");
const { generateHtmlReport, generateHeatmapReport } = require("./lib/report");
const { loadExcelSpec } = require("./lib/excel");

const program = new Command();
Expand All @@ -27,9 +27,10 @@ program
.option("--strict-body", "Enable strict validation of requestBody (JSON)")
.option("--output <file>", "HTML report output file", "coverage-report.html")
.option("--newman", "Treat input file as Newman run report instead of Postman collection")
.option("--heatmap", "Generate coverage heatmap (graph API with endpoints nodes, methods edges, and coverage highlighting)")
.action(async (swaggerFiles, postmanFile, options) => {
try {
const { verbose, strictQuery, strictBody, output, newman } = options;
const { verbose, strictQuery, strictBody, output, newman, heatmap } = options;

// Parse comma-separated swagger files
const files = swaggerFiles.includes(',') ?
Expand Down Expand Up @@ -172,21 +173,33 @@ program
`Multiple APIs (${allSpecNames.join(', ')})` :
allSpecNames[0];

const html = generateHtmlReport({
coverage,
coverageItems,
meta: {
timestamp: new Date().toLocaleString(),
specName: combinedSpecName,
postmanCollectionName: collectionName,
undocumentedRequests,
apiCount: files.length,
apiNames: allSpecNames
},
});
const reportMeta = {
timestamp: new Date().toLocaleString(),
specName: combinedSpecName,
postmanCollectionName: collectionName,
undocumentedRequests,
apiCount: files.length,
apiNames: allSpecNames
};

let html;
if (heatmap) {
html = generateHeatmapReport({
coverage,
coverageItems,
meta: reportMeta
});
console.log(`\nHeatmap report saved to: ${output}`);
} else {
html = generateHtmlReport({
coverage,
coverageItems,
meta: reportMeta
});
console.log(`\nHTML report saved to: ${output}`);
}

fs.writeFileSync(path.resolve(output), html, "utf8");
console.log(`\nHTML report saved to: ${output}`);
} catch (err) {
console.error("Error:", err.message);
process.exit(1);
Expand Down
Loading