openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Type and Enum duplicated when schema property enum as $ref

Open Ginxo opened this issue 10 months ago • 9 comments

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

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

Extra

Ginxo avatar Jan 13 '25 11:01 Ginxo