We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently, the attribute parameters readOnly and writeOnly are ignored when generating bean validation @NotNull annotation.
readOnly
writeOnly
@NotNull
Spec says:
If a readOnly or writeOnly property is included in the required list, required affects just the relevant scope. see https://swagger.io/docs/specification/data-models/data-types/#readonly-writeonly
Using @NotNull on these fields is wrong, because it fails validation in the other direction, where the attribute is intentionally not present.
5.1.1
"Example": { "type": "object", "required": ["displayName_r", "displayName_w"], "properties": { "displayName_r": { "type": "string", "readOnly": true }, "displayName_w": { "type": "string", "writeOnly": true } } },
<generatorName>jaxrs-spec</generatorName> <configOptions> <interfaceOnly>true</interfaceOnly> <returnResponse>false</returnResponse> <sourceFolder>java</sourceFolder> <useSwaggerAnnotations>false</useSwaggerAnnotations> <generatePom>false</generatePom> <dateLibrary>java8</dateLibrary> </configOptions>
Example.java
displayName_r
displayName_w
#9222: "readOnly/writeOnly not respected in jackson annotation"
Update beanValidation.mustache to respect readOnly/writeOnly markers:
beanValidation.mustache
{{#required}}{{^isReadOnly}}{{^isWriteOnly}} @NotNull {{/isWriteOnly}}{{/isReadOnly}}{{/required}} {{>beanValidationCore}}
instead of
{{#required}} @NotNull {{/required}} {{>beanValidationCore}}
The text was updated successfully, but these errors were encountered:
Bug fix for read/write issue OpenAPITools#9654
dfcd603
Successfully merging a pull request may close this issue.
Bug Report Checklist
Description
Currently, the attribute parameters
readOnly
andwriteOnly
are ignored when generating bean validation@NotNull
annotation.Spec says:
Using
@NotNull
on these fields is wrong, because it fails validation in the other direction, where the attribute is intentionally not present.openapi-generator version
5.1.1
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Example.java
-> getters ofdisplayName_r
/displayName_w
define@NotNull
Related issues/PRs
#9222: "readOnly/writeOnly not respected in jackson annotation"
Suggest a fix
Update
beanValidation.mustache
to respect readOnly/writeOnly markers:instead of
The text was updated successfully, but these errors were encountered: