Skip to content
Merged
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
12 changes: 2 additions & 10 deletions src/__tests__/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ exports[`basic > hide with a boolean value 1`] = `
"version": "0.0.0",
},
"openapi": "3.1.0",
"paths": {
"/": {
"get": undefined,
},
},
"paths": {},
"tags": undefined,
}
`;
Expand All @@ -86,11 +82,7 @@ exports[`basic > hide with a function 1`] = `
"version": "0.0.0",
},
"openapi": "3.1.0",
"paths": {
"/": {
"get": undefined,
},
},
"paths": {},
"tags": undefined,
}
`;
13 changes: 12 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,18 @@ export function removeExcludedPaths(
}
}

newPaths[key] = value;
// Build filtered value with only non-null methods
const filteredValue: OpenAPIV3_1.PathItemObject = {};
for (const method of Object.keys(value)) {
if (value[method] != null) {
filteredValue[method] = value[method];
}
}

// Only add path if it has at least one valid method
if (Object.keys(filteredValue).length > 0) {
newPaths[key] = filteredValue;
}
}

return newPaths;
Expand Down
Loading