-
-
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
Fix map parameter not a container #18220
Fix map parameter not a container #18220
Conversation
…om map properties. This solves an issue where a map parameter was not considered a container and induced generation errors.
thanks for the fix. can you please add a test or 2 in default codegen test? |
If I remember correctly, this could be the "historical" reason before even I started working on this project. |
cc @OpenAPITools/generator-core-team |
no change in samples because we didn't test map parameters in the test spec at the moment. can you add one to cpp-ue4 petstore samples?
first copy (note that we use 3.0 spec here) and then add a fake endpoint to then compile the output locally to ensure it's good. |
Will do, I have indeed tested this for my generator and it compiles fine, but i'm worried about the impact on others, although technically this was never well supported. |
@wing328 Added the test file, seems to generate correctly. |
lgtm. let's give it a try |
Map parameters now carry their container properties when generated from map properties. This solves an issue where a map parameter was not considered a container and induced generation errors.
DISCLAIMER: This is a change that may impact other generators in unexpected ways. However the code when I read it did not feel correct, as the case of map as parameter is simply not handled. It's a bit obscure to me what should and what should not be carried over from CodegenProperty into CodegenParameter but my assumption was that most things should be, especially the "isContainer" property which solves the bug i'm chasing. I've tried my best to keep it generic and logical but I think this needs a better pair of eyes from one of the core maintainers of the project.
Out of curiosity, why aren't most things carried over? For example isPrimitiveType is set explicily in the if/else cases rather than simply copied from the property. At least, from a generator template developer's perspective, having the parameters and property as similar as possible and having the same fields makes working on the mustache files that much easier. This bug was a good example of a case where the behavior was not expected as isContainer always worked for properties but in this case didn't for parameters.
I can provide an openapi spec that exhibits the issue upon request, the issue was observed using the cpp-ue4 generator. It is hard for me to test against other generators, but this should not be a neutral change. My development environment has always been incomplete and as such I am not able to easily regenerate the samples, but I do expect some changes in some of the generators.
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
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@wing328