Skip to content

Commit

Permalink
fix: correct import for anyof enums (#1371)
Browse files Browse the repository at this point in the history
Co-authored-by: Alfred Jonsson <[email protected]>
  • Loading branch information
AllieJonsson and Alfred Jonsson authored May 14, 2024
1 parent 50a7ad7 commit d3ddbdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/getters/combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,17 @@ export const combineSchemas = ({
return {
value: `typeof ${pascal(name)}[keyof typeof ${pascal(name)}] ${nullable}`,
imports: [
...resolvedData.imports.map<GeneratorImport>((toImport) => ({
...toImport,
values: true,
})),
{
name: pascal(name),
},
],
schemas: [
...resolvedData.schemas,
{
imports: [],
imports: resolvedData.imports.map<GeneratorImport>((toImport) => ({
...toImport,
values: true,
})),
model: newEnum,
name: pascal(name),
},
Expand Down
9 changes: 7 additions & 2 deletions tests/specifications/any-of.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ paths:
in: query
schema:
anyOf:
- type: string
enum: ['A']
- $ref: '#/components/schemas/A'
- type: string
enum: ['B']
- type: string
enum: ['C']
components:
schemas:
A:
type: string
enum:
- A

0 comments on commit d3ddbdd

Please sign in to comment.