openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [JAVA] [restclient] combining properties and additionalProperties generates broken Model class

Open roborobo2 opened this issue 10 months ago • 5 comments

same as fixed issues: https://github.com/OpenAPITools/openapi-generator/issues/17361 @JoaoBrlt , we have same problem with java generator and restclient library. Can you fix it please also for restclient? thank you.

Combining required properties with additionalProperties: true generates a Model class that extends HashMap. On deserialization, the given Properties are not filled, instead all properties (required and additional) are part of the Hashmap. According to https://github.com/FasterXML/jackson-databind/issues/3173 this is expected behavior for Jackson so the generated Model is wrong. This was fixed for the spring generator in https://github.com/OpenAPITools/openapi-generator/pull/11572 but its still happening in the java generator.

openapi-generator version 7.11.0/7.12.0

roborobo2 avatar Mar 12 '25 07:03 roborobo2

+1

drej1 avatar Mar 12 '25 16:03 drej1

Hi @roborobo2! 👋 I've just created the pull request #20947 to fix the issue for the restclient library. For others passing by: if you notice the same issue for another library, checkout the previous pull requests (#19706, #19711, #19713) and don't hesitate to contribute to the project. It's a fairly simple fix, so it's well suited for a first pull request if you can contribute to the project. :wink:

JoaoBrlt avatar Mar 22 '25 22:03 JoaoBrlt

Hi @JoaoBrlt when will this be released please? Thanks

drej1 avatar Apr 01 '25 11:04 drej1

Hi @drej1 @roborobo2! 👋 The pull request #20947 has been merged and the latest release v7.13.0 includes this fix so the issue should be resolved now.

JoaoBrlt avatar May 03 '25 19:05 JoaoBrlt

Same issue exists with library=microprofile / microprofileRestClientVersion=3.0.

joschi avatar Jun 13 '25 09:06 joschi