Skip to content

Commit 3f39df0

Browse files
committed
fix: ref
1 parent 3e85496 commit 3f39df0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/generateValidRootSchema.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,24 @@ export const generateValidRootSchema = (input: Types.OpenApi.Document): Types.Op
66
}
77
/** update undefined operation id */
88
for (const [path, methods] of Object.entries(input.paths || {})) {
9-
for (const [method, operation] of Object.entries(methods || {})) {
9+
const targets = {
10+
get: methods.get,
11+
put: methods.put,
12+
post: methods.post,
13+
delete: methods.delete,
14+
options: methods.options,
15+
head: methods.head,
16+
patch: methods.patch,
17+
trace: methods.trace,
18+
} satisfies Record<string, Types.OpenApi.Operation | undefined>;
19+
for (const [method, operation] of Object.entries(targets)) {
20+
if (!operation) {
21+
continue;
22+
}
23+
// skip reference object
24+
if ("$ref" in operation) {
25+
continue;
26+
}
1027
if (!operation.operationId) {
1128
operation.operationId = `${method.toLowerCase()}${path.charAt(0).toUpperCase() + path.slice(1)}`;
1229
}

0 commit comments

Comments
 (0)