I created a custom validation annotation which is similar to @javax.validation.constraints.Pattern
. For @Pattern
, swagger generates a nice schema like this:
summary: my summary
operationId: my_operation_id
parameters:
- name: myParam
in: header
required: true
schema:
maxLength: 30
pattern: ^\w+$ <--- THIS ONE
type: string
But for my annotation @CustomPattern
(let's say), it doesn't! The generated swagger.yml does not have pattern
key under schema
. How can I create one?
This is in Micronaut.
I needed to have swagger.yml generated for my controller methods' parameters.
Just stick in a @io.swagger.v3.oas.annotations.media.Schema
annotation with pattern
attribute. Or if it's a List, then you could use @io.swagger.v3.oas.annotations.media.ArraySchema(schema = @Schema(pattern = ?))
That will do.