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

Nullable enum support #1246

Closed alex-canopy closed 2 weeks ago

alex-canopy commented 2 weeks ago

Description

An enum can be null (https://swagger.io/docs/specification/v3_0/data-models/enums/#nullable-enums). Currently it prints a 🚨 unhandled "object" typeof value "null" for enum error, which is from here.

Reproducible example or configuration

type: string
nullable: true  # <---
enum:
  - asc
  - desc
  - null        # <--- without quotes, i.e. null not "null"

OpenAPI specification (optional)

No response

System information (optional)

No response

stackblitz[bot] commented 2 weeks ago

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

mrlubos commented 2 weeks ago

Hi @alex-canopy, are you using the experimental parser or is this related to the current parser?

alex-canopy commented 2 weeks ago

Experimental parser.

mrlubos commented 2 weeks ago

I'll have a look tomorrow, thanks for reporting 🙏