-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
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 FasterXML/jackson-databind#3173 this is expected behavior for Jackson so the generated Model is wrong.
This was fixed for the spring generator in #11572 but its still happening in the java generator.
openapi-generator version
7.1.0
OpenAPI declaration file content or url
additionalPropertiesWithRequiredData:
type: object
additionalProperties: true
properties:
propA:
type: integer
format: int64
propB:
type: string
required:
- propA
- propBRelated issues/PRs
Suggest a fix
The model generation should not extend HashMap, instead put additionalProperties as a HashMap inside the class and annotate it with @JsonAnySetter / @JsonAnyGetter.
aelfric, jekkel, tslmy, ingmarkellner, akuranov and 2 more