-
Notifications
You must be signed in to change notification settings - Fork 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
[JAVA][SPRING] Swagger codegen generates wrong java object for json objects with additional properties #5187
Comments
Yes, seems better. Would you do the PR ? Maybe against 2.3.0 branch since it's a breaking change. |
And ideally that would be done for all Java based codegens. |
Ok i will try to figure out where to add such changes and create a PR. Can you point me to a good starting point? |
@pumpadump There we see
... the extends logic thus comes from the existence of a parent item in the CodegenModel object. Somewhere in DefaultCodegen or AbstractJavaCodegen this likely is done. |
Hello, Is there any news about this issue ? or a workaround ? Regards, |
There are several things to consider here:
Note : to change the behavior, override the addAdditionPropertiesToCodeGenModel method and fill the additionalPropertiesType property |
@wing328 WDYT ? |
@pumpadump what does the JSON payload looks like? I want to ensure it's defined correctly. |
Any news on this? I had to hand hack my class.. doesn't include the required param in the hashmap |
I just hit this issue. I think the A first step could be to flag-enable this new way of doing things so that default behavior for I would add a requirement to allow accessing the dynamic properties map directly. |
Description
Swagger Codegen generates a java model object that extends HashMap for json objects that have the
additionalProperties:
property set. This leads to jackson only serealizing the properties added to the hashmap and ignoring all additional properties that are set explicitly in the java file.Swagger-codegen version
2.2.2
Swagger declaration file content or url
This generates a model object that starts like this:
Serializing this objects leads to a json that is missing the explicitly set properties (id, source, target).
http://stackoverflow.com/questions/31320983/jackson-serialise-map-with-extra-fields
I think instead it should generate a java object that has a hashmap as a variable and the following annotated getter and setter methods, similar to this:
as Explained here: http://www.cowtowncoder.com/blog/archives/2011/07/entry_458.html
The text was updated successfully, but these errors were encountered: