-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
14432: Do not add @Valid to Java types in "jaxrs-spec" generator #14435
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
base: master
Are you sure you want to change the base?
14432: Do not add @Valid to Java types in "jaxrs-spec" generator #14435
Conversation
`@Valid` annotation is only needed for objects, where the cascading validation is required. For standard Java types and enums it is useless. Moreover, when those annotations are there for those types - Hibernate Validator's performance degrades significantly (see: https://hibernate.atlassian.net/browse/HV-1928 and https://hibernate.atlassian.net/browse/HV-1933). I've checked other available generators, and it looks like `spring` generates those annotations properly. So I took the content of the modified files from that generator and placed to the `jaxrs-spec` one.
Updated samples, removing the excessive @Valid annotation. It is now not added to the standard Java types and enums. The implementation is identical to the `spring` generator.
modules/openapi-generator/src/main/resources/JavaJaxRS/spec/beanValidation.mustache
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pojo.mustache
Show resolved
Hide resolved
@anatoliy-balakirev can you please resolve the merge conflicts when you've time? |
Hi @wing328. I created this PR 4 months ago and it was never reviewed ever since. I don't want to spend more time on something, which seems to be not needed, sorry. I've also switched to the Spring generator in the meanwhile. If you're interested in these changes - feel free to pick them and create your own PR. |
Is this still on-track for 7.0.1? Seeing some pretty horrendous performance hits with this bug, in large request bodies. The worksaround for now is to completely disable bean validation via configOptions |
Seems to be fixed by #18302 |
@Valid
annotation is only needed for objects, where the cascadingvalidation is required. For standard Java types and enums it is useless.
Moreover, when those annotations are there for those types - Hibernate
Validator's performance degrades significantly (see:
https://hibernate.atlassian.net/browse/HV-1928 and
https://hibernate.atlassian.net/browse/HV-1933). I've checked other
available generators, and it looks like
spring
generates thoseannotations properly. So I took the content of the modified files from
that generator and placed to the
jaxrs-spec
one.PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(6.3.0) (minor release - breaking changes with fallbacks),7.0.x
(breaking changes without fallbacks)@Zomzog @lwlee2608 @cachescrubber @welshm @MelleD @atextor @manedev79 @javisst @borsch @banlevente @Zomzog