Skip to content

Commit d3ddbdd

Browse files
AllieJonssonAlfred Jonsson
and
Alfred Jonsson
authoredMay 14, 2024
fix: correct import for anyof enums (#1371)
Co-authored-by: Alfred Jonsson <alfred.jonsson@decerno.se>
1 parent 50a7ad7 commit d3ddbdd

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed
 

‎packages/core/src/getters/combine.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,17 @@ export const combineSchemas = ({
178178
return {
179179
value: `typeof ${pascal(name)}[keyof typeof ${pascal(name)}] ${nullable}`,
180180
imports: [
181-
...resolvedData.imports.map<GeneratorImport>((toImport) => ({
182-
...toImport,
183-
values: true,
184-
})),
185181
{
186182
name: pascal(name),
187183
},
188184
],
189185
schemas: [
190186
...resolvedData.schemas,
191187
{
192-
imports: [],
188+
imports: resolvedData.imports.map<GeneratorImport>((toImport) => ({
189+
...toImport,
190+
values: true,
191+
})),
193192
model: newEnum,
194193
name: pascal(name),
195194
},

‎tests/specifications/any-of.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ paths:
1414
in: query
1515
schema:
1616
anyOf:
17-
- type: string
18-
enum: ['A']
17+
- $ref: '#/components/schemas/A'
1918
- type: string
2019
enum: ['B']
2120
- type: string
2221
enum: ['C']
22+
components:
23+
schemas:
24+
A:
25+
type: string
26+
enum:
27+
- A

0 commit comments

Comments
 (0)
Please sign in to comment.