openapi-generator
openapi-generator copied to clipboard
Generate and use enum types in parameters for typescript-axios
Resolves #13439
Changes enum implementation for operators in the typescript-axios generator to more closely follow the fetch generator - generating actual types for enums defined in operators rather than using union (|
) syntax.
This should be a non-breaking change since the effective types are the same, but please correct me if i'm wrong.
PR checklist
- [x] Read the contribution guidelines.
- [x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
- [x] Run the following to build the project and update samples:
Commit all changed files. 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./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. - [x] File the PR against the correct branch:
master
(6.1.0) (minor release - breaking changes with fallbacks),7.0.x
(breaking changes without fallbacks) - [x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request. @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) @davidgamero (2022/03) @mkusaka (2022/04)
up
This should be a non-breaking change since the effective types are the same
If real enums are used (via the stringEnums
option), it will be a breaking change, since strings are not assignable to enums
@amakhrov I see, any suggestions to fix that, or should I just merge to 7.0.x?
I think targeting this for the 7.x branch is reasonable
@amakhrov I switched to merge to 7.0.x.
@amakhrov can I get your review/approval?
I'm not sure what the failing bitrise test is, could use some help with that too please.
Thanks for the review. Is there anything else I need to do to get this merged? Need someone with write access to do it please.
@amakhrov or @jimschubert?
One of the tests failed in CI.
Looks to be what has just been fixed in this PR: https://github.com/OpenAPITools/openapi-generator/pull/13526 . Perhaps need to merge in latest changes from master
here?
I updated the PR with the fix. Can't directly merge because the fix isn't on the 7.0.x
branch.
Bumping this for merging please @amakhrov.
@macjohnny
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.
Let me know if you need help fixing it.
Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account
Is there a reason why isNullable
is missing on isEnum
side?
{{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}},
We have a nullable enum field in our API
field:
type: string
nullable: true
enum: &a5
- foo
- bar
- baz
but generator generates code with non-nullable type :field: fieldEnum