[REQ] [SPRING] Add support for request parameter pattern validation
Created by: LubomirS
Is your feature request related to a problem? Please describe.
Open api v3 spec allows defining patterns in schemas, which includes places like pathParams, queryParams and headerParams. There already is support for pattern validation in both pathParams and queryParams, however, this validation cannot be used for headers. Example:
{
"name": "patternHeader",
"in": "header",
"required": true,
"schema": {
"pattern": "[0-9]+",
"type": "string"
}
}
In Spring, request header would be annotated with javax.validation.constraints.Pattern, like so:
@RequestHeader(value = "patternHeader") @Pattern(regexp = "[0-9]+") String patternHeader
which will validate if the request header matches the regex "[0-9]+".
Describe the solution you'd like
I would propose to add this feature by adding the beanValidationHeaderParams mustache file for Spring codegen, similarly how it's done with query params.
Describe alternatives you've considered
I don't think there is a better alternative solution to support this validation.