In my REST API, one of the submitted parameter values must be a code following the regex:
/[A-Z]{2}[0-9]{4}/
Is there any way, besides putting it in the description
property of the parameter, for me to indicate that the value is not valid if it does not match my regular expression?
I was not able to find any mention of regex's in the Swagger doc, except as a way to identify Patterned Fields (which is not what I want to do).
You can use a field named pattern in your api's parameters if is not a body or in your scheme definitions for properties, it use standard ECMA 262 : (http://json-schema.org/latest/json-schema-validation.html#rfc.section.3.3)
[UPDATE Jul. 2019]
OpenAPI 3 spec - https://swagger.io/docs/specification/data-models/data-types/#pattern
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With