Skip to content

Commit 72eea2d

Browse files
committed
Group union enums when intersecting allOf
1 parent 859fc64 commit 72eea2d

File tree

5 files changed

+84
-130592
lines changed

5 files changed

+84
-130592
lines changed

.changeset/witty-pumas-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"swagger-typescript-api": patch
3+
---
4+
5+
Ensure enums combined via allOf intersect with grouped union values.

src/schema-parser/complex-schema-parsers/all-of.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ import { MonoSchemaParser } from "../mono-schema-parser.js";
44
export class AllOfSchemaParser extends MonoSchemaParser {
55
override parse() {
66
const ignoreTypes = [this.config.Ts.Keyword.Any];
7-
const combined = this.schema.allOf.map((childSchema) =>
8-
this.schemaParserFabric.getInlineParseContent(
7+
const combined = this.schema.allOf.map((childSchema) => {
8+
const content = this.schemaParserFabric.getInlineParseContent(
99
this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema),
1010
null,
1111
this.schemaPath,
12-
),
13-
);
12+
);
13+
14+
if (content?.includes(this.config.Ts.Keyword.Union)) {
15+
return this.config.Ts.ExpressionGroup(content);
16+
}
17+
18+
return content;
19+
});
1420
const filtered = this.schemaUtils.filterSchemaContents(
1521
combined,
1622
(content) => !ignoreTypes.includes(content),

0 commit comments

Comments
 (0)