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

useEnums with numeric values or strings with spaces in swagger #189

Open
bradrisse opened this issue Jul 21, 2023 · 0 comments
Open

useEnums with numeric values or strings with spaces in swagger #189

bradrisse opened this issue Jul 21, 2023 · 0 comments

Comments

@bradrisse
Copy link

bradrisse commented Jul 21, 2023

"status": {
  "type": "string",
   "enum": [
      "100",
      "101",
      "102",
      "103",
     "200",
    ]
 }

gets converted to

export enum SomeDefinition {
   100 = "100",
   101 = "101",
   102 = "102",
   103 = "103",
}

which causes an unexpected token error due to numeric enum key not being valid.

before converting swagger enum array to typescript enum, can the generator check to see if the enum key is possibly numeric and if so keep the key a string?

The other issue is also enums with spaces in the enum values

Maybe 'x-enumNames' like here https://stackoverflow.com/questions/66465888/how-to-define-enum-mapping-in-openapi

@bradrisse bradrisse changed the title useEnums with numberic values in swagger useEnums with numberic values or strings with spaces in swagger Jul 21, 2023
@bradrisse bradrisse changed the title useEnums with numberic values or strings with spaces in swagger useEnums with numeric values or strings with spaces in swagger Aug 8, 2023
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

1 participant