Skip to content

Commit 7fd1a72

Browse files
author
Daniel Grossmann-Kavanagh
committed
only wrap jsonschema ValidationErrors
1 parent 58e06a3 commit 7fd1a72

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

openapi_spec_validator/validators.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import string
33

44
from jsonschema.validators import RefResolver
5+
from jsonschema.exceptions import ValidationError
56
from six import iteritems, raise_from
67

78
from openapi_spec_validator.exceptions import (
@@ -42,7 +43,11 @@ def __init__(self, validator_factory, resolver_handlers):
4243

4344
def validate(self, spec, spec_url=''):
4445
for err in self.iter_errors(spec, spec_url=spec_url):
45-
raise_from(OpenAPIValidationError(repr(err)), err)
46+
if isinstance(err, ValidationError):
47+
# wrap jsonschema exceptions with library specific version
48+
raise raise_from(OpenAPIValidationError.create_from(err), err)
49+
else:
50+
raise err
4651

4752
def iter_errors(self, spec, spec_url=''):
4853
spec_resolver = self._get_resolver(spec_url, spec)

0 commit comments

Comments
 (0)