Skip to content

Type and Enum duplicated when schema property enum as $ref #2099

@Ginxo

Description

@Ginxo

openapi-typescript version

7.5.2

Node.js version

20.11.0

OS + version

Fedora Linux 41

Description

after executing the tool with --root-types --root-types-no-schema-prefix --enum flags (since types are required for not refactoring the whole application and Schema prefix avoided due to the same reason...) some of the enums are duplicated also as type aliases, which is producing an error at TS validation time.

I'm clicking My OpenAPI schema is valid and passes the [Redocly validator](https://redocly.com/docs/cli/commands/lint/) (npx @redocly/cli@latest lint) * because it is required, I have few issues but none of them related with the enums

It is mandatory for us to use --root-types-no-schema-prefix not to affect the whole application

Reproduction

npx openapi-typescript https://api.stage.openshift.com/api/clusters_mgmt/v1/openapi -o src/types/clusters_mgmt.v1/schema.ts --root-types --root-types-no-schema-prefix --enum

Expected result

Maybe different type alias name, see case for AWSInfrastructureAccessRoleState where enum is AWSInfrastructureAccessRoleState (AWS uppercase) and type AwsInfrastructureAccessRoleGrantState (Aws upper first)

Required

  • My OpenAPI schema is valid and passes the Redocly validator (npx @redocly/cli@latest lint)

Extra

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopenapi-tsRelevant to the openapi-typescript library

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions