Its a springboot app with OAS3 .
There is a controller which accepts id as Query parameter.
@RequestMapping("/detail")
public class Controller {
@Operation(
tags = "Shop APIs",
summary ="Find Shop detail",
responses = {
@ApiResponse(responseCode = "200", description = "successful operation",
content = @Content(schema = @Schema(implementation = FacilitiesResponse.class)))
},
parameters = {
@Parameter(in = ParameterIn.QUERY, name = "id",required = true, style = ParameterStyle.DEFAULT,explode=Explode.FALSE,schema = @Schema(pattern = "[a-zA-Z0-9]{5,15}")),
}
)
@GetMapping()
public Flux<DetailResponse> getDetail(final @RequestParam Optional<String> id){
//return statement
}
}
I have a requirement that query param -"id" accepts multiple comma separated value & each id follow REGEX [a-zA-Z0-9]{5,15}. i.e each should be 5-15 in length and should be consisted of a-z, A-Z and 0-9 only eg 2RXB859H4IWSF,2RXB859H4IWSI
for this I have added explode as false and pattern as shown below.
parameters = {
@Parameter(in = ParameterIn.QUERY, name = "id",required = true,style = ParameterStyle.DEFAULT,explode=Explode.FALSE,schema = @Schema(pattern = "[a-zA-Z0-9]{5,15}")),
}
But when I try from swagger what I observed :
it is just checking pattern upto 5 character only i.e id value as @ is not allowed is correct but if I provide @12345 is being allowed which is not correct
2RXB859H4IWSF]},##2RXB859H4IWSF as id value is being treated as single value. It should be treated as two different id and pattern should be applied on both of them separately.
even 2RXB859H4IWSF]} as id value is being allowed which should not be. Its not following pattern that I have added above