Skip to content

Commit 7185887

Browse files
committed
test: add scenarios of allOf incorrectly add property with schema name
1 parent 462412f commit 7185887

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/types.gen.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ export type QuxMapped = FooMapped & {
4444
qux?: boolean;
4545
};
4646

47+
export type FooUnion = ({
48+
id: 'bar';
49+
} & BarUnion) | ({
50+
id: 'baz';
51+
} & BazUnion);
52+
53+
export type BarUnion = {
54+
id?: string;
55+
bar?: string;
56+
};
57+
58+
export type BazUnion = {
59+
id?: string;
60+
baz?: string;
61+
};
62+
63+
export type QuxExtend = FooUnion & {
64+
id?: 'QuxExtend';
65+
};
66+
4767
export type ClientOptions = {
4868
baseUrl: `${string}://${string}` | (string & {});
4969
};

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/types.gen.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ export type QuxMapped = FooMapped & {
4444
qux?: boolean;
4545
};
4646

47+
export type FooUnion = ({
48+
id: 'bar';
49+
} & BarUnion) | ({
50+
id: 'baz';
51+
} & BazUnion);
52+
53+
export type BarUnion = {
54+
id?: string;
55+
bar?: string;
56+
};
57+
58+
export type BazUnion = {
59+
id?: string;
60+
baz?: string;
61+
};
62+
63+
export type QuxExtend = FooUnion & {
64+
id?: 'QuxExtend';
65+
};
66+
4767
export type ClientOptions = {
4868
baseUrl: `${string}://${string}` | (string & {});
4969
};

packages/openapi-ts-tests/specs/3.0.x/discriminator-all-of.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,29 @@ components:
6767
properties:
6868
qux:
6969
type: boolean
70+
FooUnion:
71+
oneOf:
72+
- $ref: '#/components/schemas/BarUnion'
73+
- $ref: '#/components/schemas/BazUnion'
74+
discriminator:
75+
propertyName: id
76+
mapping:
77+
bar: '#/components/schemas/BarUnion'
78+
baz: '#/components/schemas/BazUnion'
79+
BarUnion:
80+
type: object
81+
properties:
82+
id:
83+
type: string
84+
bar:
85+
type: string
86+
BazUnion:
87+
type: object
88+
properties:
89+
id:
90+
type: string
91+
baz:
92+
type: string
93+
QuxExtend: # this is a schema that extends the FooUnion schema
94+
allOf:
95+
- $ref: '#/components/schemas/FooUnion'

packages/openapi-ts-tests/specs/3.1.x/discriminator-all-of.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,29 @@ components:
6767
properties:
6868
qux:
6969
type: boolean
70+
FooUnion:
71+
oneOf:
72+
- $ref: '#/components/schemas/BarUnion'
73+
- $ref: '#/components/schemas/BazUnion'
74+
discriminator:
75+
propertyName: id
76+
mapping:
77+
bar: '#/components/schemas/BarUnion'
78+
baz: '#/components/schemas/BazUnion'
79+
BarUnion:
80+
type: object
81+
properties:
82+
id:
83+
type: string
84+
bar:
85+
type: string
86+
BazUnion:
87+
type: object
88+
properties:
89+
id:
90+
type: string
91+
baz:
92+
type: string
93+
QuxExtend: # this is a schema that extends the FooUnion schema
94+
allOf:
95+
- $ref: '#/components/schemas/FooUnion'

0 commit comments

Comments
 (0)