Skip to content

Commit 09f6beb

Browse files
committed
feat: rework more functions to resuse withComment step
DX-592
1 parent 652c36f commit 09f6beb

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/openapi-generator/src/optimize.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ export function filterUndefinedUnion(schema: Schema): [boolean, Schema] {
168168
if (schemas.length === 0) {
169169
return [true, { type: 'undefined' }];
170170
} else if (schemas.length === 1) {
171-
return [true, schemas[0]!];
171+
return [true, withComment(schemas[0]!, schema)];
172172
} else {
173-
return [true, { type: 'union', schemas }];
173+
return [true, withComment({ type: 'union', schemas }, schema)];
174174
}
175175
}
176176

@@ -193,11 +193,6 @@ export function optimize(schema: Schema): Schema {
193193
continue;
194194
}
195195
const [isOptional, filteredSchema] = filterUndefinedUnion(optimized);
196-
197-
if (optimized.comment) {
198-
filteredSchema.comment = optimized.comment;
199-
}
200-
201196
properties[key] = filteredSchema;
202197

203198
if (schema.required.indexOf(key) >= 0 && !isOptional) {

0 commit comments

Comments
 (0)