open-api
open-api copied to clipboard
BUG: json schema validator is not parsing correctly the PATTERN parameter
The error can be reproduced simply adding the pattern key in a parameter
"email": {
"type": "string",
"pattern": "S+@S+\.S+"
}
when you pass some parameters to the validation-error shows this message:
{
"path": "email",
"errorCode": "pattern.openapi.requestValidation",
"message": "should match pattern "S+@S+\.S+",
"location": "body"
}
as you can see it automatically adds quotes (") at the beginning and at the end of the regex and it is actually testing for THAT specific regex!
To pass this regex validation in fact you must pass this json payload to you body
{
"email": "\"S@SSS\""
}
instead of <anystring>@<anystring>.<anystring> as intended
@giowe can you please submit a pr to fix this?
@giowe I think you need to escape your backslash. Passing the json in was a false positive since the regex is rather permissive.
"pattern": "S+@S+\\.S+"
Okay to close?