Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum serialization with negative values duplicates enum keys #335

Open
bzh2610 opened this issue Nov 21, 2024 · 1 comment
Open

Enum serialization with negative values duplicates enum keys #335

bzh2610 opened this issue Nov 21, 2024 · 1 comment

Comments

@bzh2610
Copy link

bzh2610 commented Nov 21, 2024

I have an OpenAPI spec generated in JSON containing the following enum :

 "CustomType": {
   "enum": [0, 1, 2, 3, -1],
   "type": "integer",
   "format": "int32"
 },

If I check the custom typescript file generated, I get the following :

export enum CustomType {
  $0 = 0,
  $1 = 1,
  $2 = 2,
  $3 = 3,
  $1 = -1,
}

Which doesn't compile as we redeclare $1 twice.
Is there any workarround or configuration I missed ?

I can provide a code sandox if needed for reproduction.

@Colleoni
Copy link

I encounter a similar behaviour with special characters:

AgeRangeEnum:
  enum:
  - 18+
  - <18
  type: string
  description: |-
    * `18+` - Adult
    * `<18` - Underage

which results in

export enum AgeRangeEnum {
 $18 = '18+',
 $18 = '<18'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants