-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] Wrong expression used to detect required properties #13548
Labels
Comments
5 tasks
thanks for reporting the issue, I've filed #13630 to fix it. (will file another for jersey2 later) |
@meyer-r can you please pull the latest master to give it another try? |
FYI. #13646 fixed the jersey2, jersey3 templates. |
I checked latest master and the issue is fixed there, thanks! |
thanks for the confirmation |
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report Checklist
Description
Some mustache templates use the expressions "{{#isRequired}}" and "{{^isRequired}}" to differentiate between required
and optional properties. But "isRequired" is not available as a property (at least it's not contained in the debug
model file when the generator is run with the "debugModels" option).
It looks like the "required" property should be used instead.
The consequence is that "{{#isRequired}}" always evaluates to false, and "{{^isRequired}}" always evaluates to true.
So code to be generated for required properties is never generated, and all properties are treated as non-required.
This mainly affects the "java" generators, but also some other languages.
openapi-generator version
v6.1.0 (also tested with latest master)
OpenAPI declaration file content or url
Generation Details
openapi-generator-cli generate -i ./openapi.yaml -g java -o ./generated/java/
Steps to reproduce
When the openapi file above is generated with "java", the "SomeSchema" class contains the following code in the
"validateJsonObject" method:
Both the required and optional property are handled the same, and the generated comment even states that
"required_property" is recognized as an optional field.
Expected output for "required_property" would be according to the template code in the "{{#isRequired}}" condition:
Suggest a fix
Replace all references to "isRequired" with "required".
The text was updated successfully, but these errors were encountered: