Pattern (and other?) validation doesnt work when referenced via $ref
Issue #44
resolved
This was raised by @imthedoctor in discussion in #9
"definitions": {
"PatternObject": {
"type": "object",
"properties": {
"patternByRef": {
"$ref": "#/definitions/Pattern"
},
"patternInline": {
"type": "string",
"pattern": "b+a"
}
}
},
"Pattern": {
"type": "string",
"pattern": "a+b"
}
}
Both pattern validations incorrectly passing for requests with invalid fields, e.g.
{
"patternInline": "foo",
"patternByRef": "bar"
}
Initial thought is the schema validator may not be following multiple levels of $ref
redirection and so isn't generating the appropriate validation messages.
Comments (3)
-
-
Mysterious. By using the branch v2.0 both fields are not working as expected.
-
reporter - changed status to resolved
Available in v1.4.7
- Log in to comment
I can verify that the validation for
patternByRef
isn't working. ThepatternInline
is working as expected.This is due to this bug in swagger-core: https://github.com/swagger-api/swagger-core/issues/2181
The
ModelImpl
simply has not pattern field. So it simply gets lost while reading the Swagger schema. Thus making validation impossible.I don't see it happen that this bug will be fixed in Swagger 2.0 as the development is strong for OpenAPI 3.0. And I can't imagine a workaround in the S-R-V at the
SchemaValidator
. The necessary information is simply not there.