Springboot API Input Regex validations fail after migration to Open API Swagger

119 Views Asked by At

I have migrated my springboot application from springfox to springdoc-openapi-ui swagger and post which the input regex validations that I have on controller started failing and the openAPI swagger throws out an error stating the following validation message even if I supply the right input value

enter image description here

This is my springboot controller method signature

 public ServiceResponse<ResponseDTO> getNameByIdV2(
            @Pattern(regexp = "^[\\p{IsAlphabetic}\\p{IsDigit}-]+$", flags = {Pattern.Flag.CASE_INSENSITIVE}, message = "INVALID ID")
            @RequestParam(value = "id", required = true) String id
    )

Is there a way to fix this issue without changing the regex format or bypass/suppress swagger UI validations and let the backend handle validations and return a 400 error if the validation fails (Same behavior as springfox swagger)?

0

There are 0 best solutions below