-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support Composed Constraints #4799
Comments
Hi @michael-arndt-gcx, I tried to extend your idea into a PR since this issue bugs me for some time: #4801 It works for me locally. |
Hey, really nice to see someone pick this up! I've also started, but then it came clear I'll loose my day-job, so other things take priority 😅 One problem with mapping bean validation to OpenAPI is that Bean Validation allows an arbitrary number of constraints, even of the same type, whereas OpenAPI allows only up to one. So for example you could add 100 different minimum value constraints. In Bean Validation, they would all be evaluated, and every violated constraint would be reported. That makes the adoption a bit less trivial, if For Pattern it's worse. In theory we could create the conjunction of multiple patterns with a positive lookahead (e.g. What do you think? Here's my work-in-progress, just for reference #4811 |
Jakarta Bean Validation allows to compose constraints as described in 3.3. Constraint composition.
I'd like to implement basic support for this. My idea would be to add a preprocessing step to
swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java
Line 1560 in df88c8a
which flattens all Annotations. That means: when an annotation is annotated with
javax.validation.Constraint
, all its annotations are treated as if all annotations are on the annotated element.This has been requested as feature e.g. in springdoc/springdoc-openapi#1486
The text was updated successfully, but these errors were encountered: