-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[typescript] Fix generation of enum models #7529
Conversation
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Is there anyway I can pick this change up prior to a proper 5.0 release? im using the docker cli approach with |
@duhseekoh the |
I confirmed in the output i'm using 5.0.0-SNAPSHOT. An enum outlined in the swagger.json like this, isn't having a type generated for it when using the 5.0.0-SNAPSHOT + typescript-axios.
|
The fix in this PR is for the new typescript generator. |
Oh, is the direction to use the new typescript generator? Is typescript-axios deprecated? |
@duhseekoh the |
It turns out typescript-axios does in fact generate TS enums for top level spec enums. What I discovered, after pulling the source for openapi-generator down and through some trial and error, is that the generator fails when it hits an enum with I can create a bug if needed. But first I was curious if it was expected behavior that it should fail when including that extra attribute? Fails
Works (generates Color enum)
|
Due to the fact that the consolidated typescript template was forked from master so long ago, there are still some bugs left that where fixed for other typescript generators in the meantime. This is one of them.
This fixes #665 for the consolidated typescript generator. (With sample definition)
The issue there is, that top-level enum schemas, which are not nested as attributes of other schemas are just generated as normal object schemas, which is not suited to represent the different allowed values.
Original fix for typescript-node was in PR #2266, merged as 8417c5b in version 4.1.0.
CC: @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)
PR checklist
./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH.master