Hello guys I'm trying to get the validation on the YAML
- name: campo
in: query
schema:
type: string
pattern: '[S|N]' #pattern
maxLength: 1
Using maven spring boot and delegate. On the RestController I added annotation @Validated and I'm able to validate required=true fields, but if fields are not require, as per architecture design, parameter will be Optional<String>. For this java.util.Optional, trying to test and validate, throw title error:
{
"timestamp": "2020-10-21T07:50:18.651+0000",
"status": 500,
"error": "Internal Server Error",
"message": "HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.util.Optional<java.lang.String>'. Check configuration for 'metodo.campo'",
"path": "/%7BbasePath%7D/microservicio/metodo"
}
¿Anyway to solve this issue to have this Optional<String> validation proccessed correctly? We don't want to write all code for validation on Java if can be done on YAML + validation (@Valid and @Validated).
EDIT: The validation @Size and others is generated from YAML with open api version 3.0.3