smallrye-open-api
smallrye-open-api copied to clipboard
Support for Composite Constraints
A composite constraint such as this does not appear in the open api schema when a REST method parameter is annotated. The validation still occurs at runtime though.
@Max(100000)
@Min(0)
@ConstraintComposition(CompositionType.AND)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE,
ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RUNTIME)
@Constraint(validatedBy = {})
@Documented
public @interface CustomIntConstraint {
String message() default "";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@GET
@Path("/{id}")
public Response test(@CustomIntConstraint @PathParam("id") int id) {}
It would be really awesome if this worked. I'm testing using this version:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
<version>3.15.1</version>
</dependency>
which I think corresponds to version 3.10.0 of smallrye open api.
This should already work, so I wonder if it's something to do with the location of the constraint. I'll try to look into this one soon.