parameters/body should catch all schema errors

This commit is contained in:
Domen Kožar 2018-09-12 17:43:07 +01:00
parent 6bdd1a6756
commit b66ec04ac2
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
2 changed files with 6 additions and 6 deletions

View file

@ -4,7 +4,7 @@ from collections import defaultdict
from json import loads
from openapi_core.schema.media_types.exceptions import InvalidMediaTypeValue
from openapi_core.schema.schemas.exceptions import InvalidSchemaValue
from openapi_core.schema.schemas.exceptions import OpenAPISchemaError
MEDIA_TYPE_DESERIALIZERS = {
@ -43,10 +43,10 @@ class MediaType(object):
try:
unmarshalled = self.schema.unmarshal(deserialized, custom_formatters=custom_formatters)
except InvalidSchemaValue as exc:
except OpenAPISchemaError as exc:
raise InvalidMediaTypeValue(exc)
try:
return self.schema.validate(unmarshalled, custom_formatters=custom_formatters)
except InvalidSchemaValue as exc:
except OpenAPISchemaError as exc:
raise InvalidMediaTypeValue(exc)

View file

@ -10,7 +10,7 @@ from openapi_core.schema.parameters.exceptions import (
EmptyParameterValue,
)
from openapi_core.schema.schemas.enums import SchemaType
from openapi_core.schema.schemas.exceptions import InvalidSchemaValue
from openapi_core.schema.schemas.exceptions import OpenAPISchemaError
log = logging.getLogger(__name__)
@ -110,10 +110,10 @@ class Parameter(object):
try:
unmarshalled = self.schema.unmarshal(deserialized, custom_formatters=custom_formatters)
except InvalidSchemaValue as exc:
except OpenAPISchemaError as exc:
raise InvalidParameterValue(self.name, exc)
try:
return self.schema.validate(unmarshalled, custom_formatters=custom_formatters)
except InvalidSchemaValue as exc:
except OpenAPISchemaError as exc:
raise InvalidParameterValue(self.name, exc)