-
-
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
[BUG] [JAVA] Referencing Object with additionalPorperties does not import HashMap in Model #3456
Comments
Why didn't the Bot pick this issue up and added Tags to it? |
I ran into the same issue. Would be amazing to see some progress here |
I there any possible update on this? |
Hey, I've just tested this in master and it's working as I would expect (HashMap is imported, but the dynamic object has no initializer and would default to null). Would you mind giving it a try if possible? I think it was fixed as a result of #6052 which I'd implemented as a result of conversations on Slack, iirc. |
@jimschubert Thanks for looking into this. I tried the 5.0.0-Beta The HashMap is now imported correctly, but the Object with the additional Properties does not extend HashMap any more. My Objects look like this:
|
@FloKaemmerer The objects are no longer treated as a HashMap, but rather as a regular object where I don't have context around the change from #6518, but I assume it has to do in part with how You could refer to my comment on additionalProperties in #6849 to understand some issues with that property itself. As OpenAPI Specification is a schema validation specification and not a structural definition specification, the implementation in #6518 using a property bag arguably matches the intent of the specification more closely. If schemas containing additionalProperties extend HashMap, this would mean:
The new approach also follows the best practice to "prefer composition over inheritance" If you have specific questions about the new approach I think @wing328 would be happy to discuss. |
@jimschubert Thanks for clearing that up, I missed that in the changelog. But the problem is that the generator tries to initialize the Object that has the additional properties as a HashMap. (See the Code in my previous comment) |
@FloKaemmerer I apologize that I didn't make it more clear in my first comment on this thread, but the changes I've shown above are on master, not in 5.0.0-beta. This is what BrokenDTO would look like on master: We'll have a second beta release later this week, but if you want to try things out now you could use the latest docker image. |
@jimschubert hi i tried to use open api generator version 5.1.1 |
@jass-trix hi did you fix that hashMap import error i am also getting the same error in 5.1.0 version.please reply to me if you have fixed it |
hi, recently i've just tried to recreate once again to create map in my model
i don't know what happen, but this time it works for me and it show no error or missing import from my side |
Bug Report Checklist
Description
Generating Model for a Object that references an object that has "additionalProperties" fails to generate the import for HashMap
openapi-generator version
affected Version(s): 4.0.0 to 4.0.3
Not affected: 3.3.4 (sets the field to null, so no import is needed here)
OpenAPI declaration file content or url
Snipped:
gist: https://gist.github.com/FloKaemmerer/54a9663183688b0d5658a8064c32f695
Command line used for generation
mvn clean compile
used pom: https://gist.github.com/FloKaemmerer/9789a0fc5bfca47b6c4cf50c7573434b
Steps to reproduce
Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: