-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[BUG][JAVA] Not specifying additionalProperties should generate the Map #20139
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
Comments
did you try setting |
Hi @wing328, I have this property in the
Could it be that it is not taken into account ? |
Ah. I can only assure this option works for One way to check is to remove the option or set the option to true to see if there's any change in the output |
For the <generatorName>java</generatorName>
<configOptions>
<disallowAdditionalPropertiesIfNotPresent>false</disallowAdditionalPropertiesIfNotPresent>
</configOptions> However, if I set |
@ncelerier Please can you help confirm if this is the case for the default library and the |
Hello, sorry for this late response. Forget what I said about the Here is a recap of the current behaviour using version 7.11.0 :
|
Hey, @wing328, sorry for taking so long, but I think I see the cause of the issue: Line 2868 in de310f6
isDisallowAdditionalPropertiesIfNotPresent is not taken into account at this point, so addAdditionPropertiesToCodeGenModel is never called, which means CodegenModel.additionalPropertiesType is never set here:Line 2333 in de310f6
My idea is to add another if-else branch to this block with isDisallowAdditionalPropertiesIfNotPresent , but since DefaultGenerator is such a fundamental class, I want to know if simply adding a test case like givenAdditionalPropertiesNotDefinedAndIsDisallowAdditionalPropertiesIfNotPresentIsFalseWhenGenerateModelThenAdditionalPropertiesTypeIsObject is enough, or if there's more involved.Also, for the next part of this issue:
I see that this is because Line 538 in de310f6
Does this mean that not much can be done without a complete rewrite? I'm not sure if it's worth changing if that's the case |
@wing328 @martin-mfg , please what are your thoughts? |
Bug Report Checklist
Description
Hello,
Regarding
additionalProperties
and the specification here: https://json-schema.org/understanding-json-schema/reference/object#additionalproperties, I think there might be a bug in the Java spring generator.I'm not specifying the
additionalProperties
property and in this case, because of the specification mentioning:I would expect the
JsonWebKey
generated class to contain theMap<String, Object> additionalProperties
(and get/put methods) to be generated. But it is not !It seems the only way to generate this map is to use either:
Or:
Which I would like to avoid and shouldn't be necessary.
Am I missing something ?
Thank you for your help !
openapi-generator version
7.10.0 (current latest)
7.11.0-SNAPSHOT (2b891f6)
OpenAPI declaration file content or url
My
src/main/resources/swagger/swagger.yaml
file:Generation Details
I'm using this
pom.xml
:https://gist.github.com/ncelerier/1729b37b6f9d37aefc8af33926fed07b
Steps to reproduce
Running
mvn clean install
, then looking at the generated file if the Map is generated or not:target/generated-sources/openapi-server/src/main/java/com/example/models/JsonWebKey.java
Related issues/PRs
Suggest a fix
I can suggest something but I would like to know first if this is really a bug or if I am missing something.
The text was updated successfully, but these errors were encountered: