-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Fixes the non-working query parameter when it's an Enum #20210
base: master
Are you sure you want to change the base?
Fixes the non-working query parameter when it's an Enum #20210
Conversation
You might need to check in a new spec that uses this code path. It would be good to check two samples in. One with the existing code and how it behaves and one with the change. At first glance I am unsure this change is correct for all cases, I think it may depend on how the spec defines serialization of the query params? |
e3cbdde
to
c539f85
Compare
How do I create the generator-specific samples? Can I add a Spec for
Not sure how to proceed. |
c539f85
to
e00f574
Compare
According to the spec, What's causing the trouble is that referenced enum is not considered a primitive type (while inline enums are primitive, I believe). It happens here: Lines 4343 to 4348 in 8ce332a
For referenced enums, the type variable is the referenced model name (WidgetType in your example spec), and not the actual type of the referenced model (string ).
There is even a unit test that verifies this particular behavior: Line 4832 in 8916987
I'm not sure if other generators are also buggy currently, or whether they somehow expect this behavior. Perhaps @wing328 knows more (he added the abovementioned unit test) One way to fix it specifically for the
Looks like |
@amakhrov, That issue might be directly relevant to the discussion. |
Yeah, it should work. Im still concerned that with this approach we'll likely need to make the same update in other TS generators - instead of having a solution that applies to them all. |
e00f574
to
19e2141
Compare
modules/openapi-generator/src/main/resources/typescript/api/api.mustache
Outdated
Show resolved
Hide resolved
…i.mustache Co-authored-by: Alexey Makhrov <amakhrov@gmail.com>
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.
looks good to me!
ideally we also have some tests or samples for that. maybe just an issue-specific minimal sample to start with (like this one)?
perfectly fine with me to add another sample folder and include it in the CI for testing to ensure it's covered moving forward |
We can use Echo API to test it; https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml#L212 PM me via Slack so that we can work together to add the test. https://join.slack.com/t/openapi-generator/shared_invite/zt-2uoef5v0g-XGwo8~2oJ3EoziDSO1CmdQ |
Fixes the non-working query parameter when it's a Enum.
Previously, it'd try to iterate through a string, thus creating parameters like
&1=s&2=t&3=r...
✅ Validated on the Spec with Enum param.
Based on this fix.
@amakhrov
@davidgamero
@mkusaka
@joscha
@petejohansonxo
@macjohnny
@topce
@akehir
PR checklist
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
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)Reproducer Spec