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

String enums #58

Closed
alesdvorakcz opened this issue Jun 24, 2020 · 7 comments · Fixed by #61 or #62
Closed

String enums #58

alesdvorakcz opened this issue Jun 24, 2020 · 7 comments · Fixed by #61 or #62
Assignees
Labels
enhancement New feature or request next release

Comments

@alesdvorakcz
Copy link

alesdvorakcz commented Jun 24, 2020

Hello,
Is there any way how to easily change how enums are generated?

Shema

DayOfWeek: {
  enum: [
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
  ],
  type: "string"
},

Instead of this

export enum DayOfWeek {
  Sunday = "Sunday",
  Monday = "Monday",
  Tuesday = "Tuesday",
  Wednesday = "Wednesday",
  Thursday = "Thursday",
  Friday = "Friday",
  Saturday = "Saturday",
}

I would like to have this

export type DayOfWeek = 
  | "Sunday" 
  | "Monday" 
  | "Tuesday" 
  | "Wednesday" 
  | "Thursday" 
  | "Friday" 
  | "Saturday";

Thanks in advance

@js2me
Copy link
Member

js2me commented Jun 24, 2020

Hello @alesdvorakcz ! :)
Thanks for this issue, I think it looks like the feature request.
I will add the specific CLI flag (something like --union-enums) to swagger-typescript-api tool which will generate all enums as union type and it will help you.

@js2me js2me added the next major release This changes of code will added at next major release (*.0.0) label Jun 24, 2020
@js2me js2me self-assigned this Jun 24, 2020
@js2me js2me added the enhancement New feature or request label Jun 24, 2020
@js2me
Copy link
Member

js2me commented Jun 25, 2020

It will be in the next major release 2.0 (branch v2)

@js2me js2me added the v2 label Jun 25, 2020
@alesdvorakcz
Copy link
Author

Perfect, Thanks!
Any ETA? Is there something I can help with?

@js2me
Copy link
Member

js2me commented Jun 25, 2020

@alesdvorakcz is that very needed for you?
If it is then I can add it in the next release (2-3 hours) (with custom templates)

@js2me
Copy link
Member

js2me commented Jun 25, 2020

version 2.0.0 will be released at the end of the next week

@alesdvorakcz
Copy link
Author

Dont worry about it, I can wait.

@js2me js2me added next release and removed next major release This changes of code will added at next major release (*.0.0) v2 labels Jun 25, 2020
@js2me js2me linked a pull request Jun 25, 2020 that will close this issue
@js2me js2me mentioned this issue Jun 26, 2020
@js2me js2me closed this as completed in #62 Jun 26, 2020
@js2me
Copy link
Member

js2me commented Jun 26, 2020

@alesdvorakcz this feature has been added in 1.10.0 version. Thanks for this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request next release
Projects
None yet
2 participants