hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.39k stars 107 forks source link

Missing enums in the generated types for swagger v2 #1200

Closed 1saifj closed 3 weeks ago

1saifj commented 3 weeks ago

Hello,

I'm encountering an issue where enums defined in the OpenAPI (Swagger v2) specification are not fully represented in the generated TypeScript types using your tool.

For example, in my swagger.json, I have the following enum definition:

"employment_type": {
    "enum": [
        "part_time",
        "full_time"
    ]
}

However, the generated TypeScript enum only includes one of the values:

export enum EnumEmploymentTypeEnum {
    PartTime = 'part_time'
}

As you can see, the 'full_time' value is missing from the generated enum.

Is there a known issue with enum generation, or am I missing something in the configuration?

Reproducible example or configuration

https://stackblitz.com/edit/hey-api-client-fetch-example-fsefew?file=generated%2Ftypes.gen.ts

OpenAPI specification (optional)

swagger.json

System information (optional)

No response

stackblitz[bot] commented 3 weeks ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

mrlubos commented 3 weeks ago

@1saifj Please add an OpenAPI spec with which I could replicate the issue!

1saifj commented 3 weeks ago

@1saifj Please add an OpenAPI spec with which I could replicate the issue!

OpenAPI specification (optional)

swagger.json

mrlubos commented 3 weeks ago

Where's the full-time enum value in that spec @1saifj?

1saifj commented 3 weeks ago

the enums getting generated without any issues, this was a mistake in my swagger generated from the backend side. Thank you very much for your efforts in this project @mrlubos ❤️

1saifj commented 3 weeks ago

however this is the correct swagger file: [Uploading swagger.json…]()