Skip to content

Commit afe0291

Browse files
authored
Merge pull request #50 from p1c2u/fix/type-validator-error-msg-formatting-fix
type validator error msg formatting fix
2 parents 0105f28 + dc69362 commit afe0291

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: openapi_schema_validator/_validators.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def type(validator, data_type, instance, schema):
9191
return
9292

9393
if not validator.is_type(instance, data_type):
94-
yield ValidationError("%r is not of type %s" % (instance, data_type))
94+
data_repr = repr(data_type)
95+
yield ValidationError("%r is not of type %s" % (instance, data_repr))
9596

9697

9798
def format(validator, format, instance, schema):

Diff for: tests/integration/test_validators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def test_oneof_discriminator(self, schema_type):
327327
assert False
328328

329329
# Check we get a non-generic, somehow usable, error message when a discriminated schema is failing
330-
with pytest.raises(ValidationError, match="'bad_string' is not of type integer"):
330+
with pytest.raises(ValidationError, match="'bad_string' is not of type 'integer'"):
331331
validator.validate({
332332
"discipline": "mountain_hiking",
333333
"length": "bad_string"

0 commit comments

Comments
 (0)