Skip to content

Commit 458d571

Browse files
committed
Apply OpenAPI overlay
1 parent c72d4ce commit 458d571

File tree

5 files changed

+154
-152
lines changed

5 files changed

+154
-152
lines changed

bin/cli.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,12 @@ async function run(oaFile, options) {
254254
// Apply OpenAPI overlay actions
255255
if (options.overlaySet) {
256256
const resOverlay = await openapiFormat.openapiOverlay(resObj, options);
257-
if (resOverlay?.resultData &&
258-
(resOverlay.resultData.unusedActions || resOverlay.resultData.appliedActions || resOverlay.resultData.totalActions)) {
257+
if (
258+
resOverlay?.resultData &&
259+
(resOverlay.resultData.unusedActions ||
260+
resOverlay.resultData.totalUsedActions ||
261+
resOverlay.resultData.totalActions)
262+
) {
259263
cliLog.unusedActions = resOverlay.resultData.unusedActions || [];
260264
cliLog.totalUsedActions = resOverlay.resultData.totalUsedActions || 0;
261265
cliLog.totalUnusedActions = resOverlay.resultData.totalUnusedActions || 0;
@@ -358,7 +362,7 @@ async function run(oaFile, options) {
358362
}
359363

360364
// Show unused components
361-
if (options.overlaySet && (cliLog?.totalActions || cliLog?.appliedActions || cliLog?.unusedActions)) {
365+
if (options.overlaySet && (cliLog?.totalActions || cliLog?.totalUsedActions || cliLog?.unusedActions)) {
362366
// Log summary of actions
363367
logOut(`${consoleLine}`, options.verbose); // LOG - horizontal rule
364368
logOut(`OpenAPI Overlay actions summary:`, options.verbose);
@@ -369,7 +373,9 @@ async function run(oaFile, options) {
369373
const cliOut = [];
370374
cliLog.unusedActions.forEach(action => {
371375
const description = action.description || 'No description provided';
372-
cliOut.push(`- Target: ${action.target}\n Type: ${action.update ? 'update' : action.remove ? 'remove' : 'unknown'}`);
376+
cliOut.push(
377+
`- Target: ${action.target}\n Type: ${action.update ? 'update' : action.remove ? 'remove' : 'unknown'}`
378+
);
373379
});
374380

375381
if (cliLog.unusedActions.length > 0) {

openapi-format.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const {parseFile, writeFile, stringify, detectFormat, parseString, analyzeOpenAp
3232
const {parseTpl, getOperation} = require('./utils/parseTpl');
3333
const {writePaths, writeComponents, writeSplitOpenAPISpec} = require('./utils/split');
3434
const {dirname, extname} = require('path');
35-
const { openapiOverlay, resolveJsonPath, resolveJsonPathValue} = require('./utils/overlay');
35+
const {openapiOverlay, resolveJsonPath, resolveJsonPathValue} = require('./utils/overlay');
3636

3737
/**
3838
* OpenAPI sort function
@@ -1159,5 +1159,5 @@ module.exports = {
11591159
analyzeOpenApi: analyzeOpenApi,
11601160
changeCase: changeCase,
11611161
resolveJsonPath: resolveJsonPath,
1162-
resolveJsonPathValue: resolveJsonPathValue,
1162+
resolveJsonPathValue: resolveJsonPathValue
11631163
};

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"convert",
1313
"rename",
1414
"case",
15+
"generate",
16+
"overlay",
1517
"cli"
1618
],
1719
"homepage": "https://github.com/thim81/openapi-format#readme",
@@ -57,6 +59,7 @@
5759
"utils/file.js",
5860
"utils/filtering.js",
5961
"utils/logging.js",
62+
"utils/overlay.js",
6063
"utils/parseTpl.js",
6164
"utils/sorting.js",
6265
"utils/split.js",

0 commit comments

Comments
 (0)