Open ardc-shorn opened 2 years ago
Commit that introduced the issue: https://github.com/OpenAPITools/openapi-generator/commit/0060dfd1#diff-d34f77bd237cdd0449fb17e44bf5485ecac1a2fa5b5a329943ac128bb12fb222
{{^useBeanValidation}}
{{#required}}@NotNull{{/required}}
{{/useBeanValidation}}
I don't yet have a good grasp of Mustache templating or the openapi template variable system.
But shouldn't the fact that my openapi config is set to useBeanValidation: "false"
mean that the @NotNull
annotation should not be generated?
Am I doing something wrong with the way I'm setting the variable from Gradle?
https://github.com/au-research/raido-v2/blob/895de24f6dc9ec3a360ba04acf0f3ee1355b6d59/api-svc/idl-raid-v2/build.gradle#L141
Bug Report Checklist
Description
JavaSpring generator creates java files with
@NotNull
but there's no import for that symbol, resulting in javac errorcannot find symbol
.openapi-generator version
6.2.1
This is a regression, was working on 6.2.0.
OpenAPI declaration file content or url
Full file: https://github.com/au-research/raido-v2/blob/895de24f6dc9ec3a360ba04acf0f3ee1355b6d59/api-svc/idl-raid-v2/src/admin-experimental.yaml#L334
Generation Details
Project uses the Gradle plugin to generate, full configuration is here: https://github.com/au-research/raido-v2/blob/895de24f6dc9ec3a360ba04acf0f3ee1355b6d59/api-svc/idl-raid-v2/build.gradle#L136
I think the relevant configuration item might be:
openApiNullable: "false"
anduseBeanValidation: "false"
?Generates code like:
Steps to reproduce
openApiGenerate
taskjavac
fails with errorcannot find symbol
Suggest a fix
If
openApiNullable
anduseBeanValidation
set to false -6.2.1
should not generate the@NotNull
annotation.6.2.0
does not generate the annotation.Workaround
Customise
pojo.mustache
template to effective revert the effect of commit0060dfd1
. https://github.com/au-research/raido-v2/blob/main/api-svc/idl-raid-v2/src/main/resources/template/pojo.mustache#L3