You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
It seems that the combination of
Having a 3.1.0 spec
Having an object with additionalProperties: false that has a property with type: object and additionalProperties: true
Specifying the java generator with the library: native spec
Leads to a de-facto incorrect POJO that has extends HashMap<String, Object> when in fact that only applies to the child property, not the containing POJO.
openapi-generator version
The behavior did not happen in generator 7.6.0, it starts to happen in 7.7.0 and still happens to 7.11.0 and current latest in docker registry (tested as of "now"; 2025-02-27T09:39:00+0100).
Execute the generate command with the spec as specified above (with library: native); with version >7.6.0
Note that it is different without the library setting
Observe the behavior as described
Related issues/PRs
Couldn't find anything for this
Suggest a fix
I really think this is a bug - why would native implementation need the POJO to extend HashMap? This oppens the possibility to add any properties that are actually not used when sending the content to the receiving backend and/or can lead to backend error responses in our case (as additonalProperties is false) and of course we validate as such.
Thanks so much!
The text was updated successfully, but these errors were encountered:
First of all, I'd like to salute all people that help this project - it is really quite an undertaking! Thanks so much!
Bug Report Checklist
Description
It seems that the combination of
additionalProperties: false
that has a property withtype: object
andadditionalProperties: true
java
generator with thelibrary: native
specLeads to a de-facto incorrect POJO that has
extends HashMap<String, Object>
when in fact that only applies to the child property, not the containing POJO.openapi-generator version
The behavior did not happen in generator 7.6.0, it starts to happen in 7.7.0 and still happens to 7.11.0 and current
latest
in docker registry (tested as of "now";2025-02-27T09:39:00+0100
).OpenAPI declaration file content or url
Conside this very isolated
openapi.yaml
Note that
SampleObject
hasadditionalProperties: false
, but the propertysubObject
hasadditionalProperties: true
.I use the following YAML spec:
And this results in this POJO class definition (refer to the full generated source here if needed):
So even though
SampleObject
hasadditionalProperties: false
, it extendsHashMap
, which breaks our client expectations and our API we need to generate.Sidenote
Interestingly, when not specifying a
library
, the class is generated as expected.If we use this YAML spec (note the absence of
library
:We get this class definition - which is correct (again, click here for the full generated class code):
Generation Details
All details are specified above; i used docker cli, version
7.12.0-SNAPSHOT
as of now and used the simple cli commandwith the spec
Steps to reproduce
generate
command with the spec as specified above (withlibrary: native
); with version>7.6.0
library
settingRelated issues/PRs
Couldn't find anything for this
Suggest a fix
I really think this is a bug - why would
native
implementation need the POJO to extend HashMap? This oppens the possibility to add any properties that are actually not used when sending the content to the receiving backend and/or can lead to backend error responses in our case (asadditonalProperties
isfalse
) and of course we validate as such.Thanks so much!
The text was updated successfully, but these errors were encountered: