smallrye-open-api icon indicating copy to clipboard operation
smallrye-open-api copied to clipboard

Support for Composite Constraints

Open leonard-wohl opened this issue 1 year ago • 1 comments

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.

leonard-wohl avatar Oct 16 '24 19:10 leonard-wohl

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.

MikeEdgar avatar Oct 23 '24 13:10 MikeEdgar