Skip to content

Commit 4fb0b06

Browse files
committed
test: add failing test (due to missing parenthesis)
1 parent 1fcc0f1 commit 4fb0b06

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

packages/typed-openapi/tests/generator-basic-schemas.test.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,98 @@ test("getSchemaBox", async () => {
180180
}),
181181
).toMatchInlineSnapshot(`"export type _Test = Partial<{ intersection: string & number }>;"`);
182182

183+
// Direct allOf with discriminated union: (A|B|C) & D
184+
expect(
185+
await getSchemaBox({
186+
"allOf": [
187+
{
188+
"oneOf": [
189+
{
190+
"type": "object",
191+
"properties": {
192+
"category": {
193+
"type": "string",
194+
"enum": [
195+
"finance"
196+
]
197+
},
198+
"chift": {
199+
"type": "object",
200+
"properties": {
201+
"integrationId": {
202+
"type": "number"
203+
}
204+
},
205+
"required": [
206+
"integrationId"
207+
]
208+
}
209+
},
210+
"required": [
211+
"category"
212+
]
213+
},
214+
{
215+
"type": "object",
216+
"properties": {
217+
"category": {
218+
"type": "string",
219+
"enum": [
220+
"hris"
221+
]
222+
},
223+
"kombo": {
224+
"type": "object",
225+
"properties": {
226+
"integrationId": {
227+
"type": "string"
228+
}
229+
},
230+
"required": [
231+
"integrationId"
232+
]
233+
}
234+
},
235+
"required": [
236+
"category"
237+
]
238+
},
239+
{
240+
"type": "object",
241+
"properties": {
242+
"category": {
243+
"type": "string",
244+
"enum": [
245+
"it-and-security"
246+
]
247+
}
248+
},
249+
"required": [
250+
"category"
251+
]
252+
}
253+
]
254+
},
255+
{
256+
"type": "object",
257+
"properties": {
258+
"sourceName": {
259+
"type": "string"
260+
},
261+
},
262+
"required": [
263+
"sourceName",
264+
]
265+
}
266+
]
267+
}),
268+
).toMatchInlineSnapshot(`
269+
"export type _Test =
270+
| { category: "finance"; chift?: { integrationId: number } | undefined }
271+
| { category: "hris"; kombo?: { integrationId: string } | undefined }
272+
| ({ category: "it-and-security" } & { sourceName: string });"
273+
`);
274+
183275
expect(await getSchemaBox({ type: "string", enum: ["aaa", "bbb", "ccc"] })).toMatchInlineSnapshot(
184276
`"export type _Test = "aaa" | "bbb" | "ccc";"`,
185277
);

0 commit comments

Comments
 (0)