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
When setting disallowAdditionalPropertiesIfNotPresent to false, the generator should add support for additional properties to model classes for schemas that have no additionalProperties attribute. This is explicitly stated in the documentation of the generator:
If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
Instead, the generated code is the same, independent of the value for disallowAdditionalPropertiesIfNotPresent.
Generate Code from the example above with the cli command.
Check the generated file src/gen/java/org/openapitools/model/Example.java in the output path
Expected result: The class supports additional properties. As described in #1466 this means it extends from HashMap
Actual result: The class has no support for additional properties.
Without a fix for #1466 this might be less helpful, as the generated Code will not work as expected.
Suggest a fix
When checking for additionalProperties, the flag disallowAdditionalPropertiesIfNotPresent needs to be considered. Maybe ModelUtils#isMapSchema should return true in this case, as it does when additionalProperties is set explicitly.
The text was updated successfully, but these errors were encountered:
Our workaround is to set additionalModelTypeAnnotations in configOptions to @com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true). If you're using Maven, you'll find it in your pom.xml.
Bug Report Checklist
Description
When setting
disallowAdditionalPropertiesIfNotPresent
tofalse
, the generator should add support for additional properties to model classes for schemas that have noadditionalProperties
attribute. This is explicitly stated in the documentation of the generator:Instead, the generated code is the same, independent of the value for
disallowAdditionalPropertiesIfNotPresent
.openapi-generator version
5.2.1
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
src/gen/java/org/openapitools/model/Example.java
in the output pathExpected result: The class supports additional properties. As described in #1466 this means it extends from HashMap
Actual result: The class has no support for additional properties.
Related issues/PRs
A similar issue was mentioned in #10306.
Without a fix for #1466 this might be less helpful, as the generated Code will not work as expected.
Suggest a fix
When checking for additionalProperties, the flag disallowAdditionalPropertiesIfNotPresent needs to be considered. Maybe
ModelUtils#isMapSchema
should return true in this case, as it does when additionalProperties is set explicitly.The text was updated successfully, but these errors were encountered: