diff --git a/openapi_core/schema/schemas/enums.py b/openapi_core/schema/schemas/enums.py index 8b77e7c..3cfe035 100644 --- a/openapi_core/schema/schemas/enums.py +++ b/openapi_core/schema/schemas/enums.py @@ -26,3 +26,8 @@ class SchemaFormat(Enum): DATETIME = 'date-time' PASSWORD = 'password' UUID = 'uuid' + + +class UnmarshalContext(Enum): + REQUEST = 'request' + RESPONSE = 'response' diff --git a/openapi_core/validation/request/validators.py b/openapi_core/validation/request/validators.py index ccfe380..df07e05 100644 --- a/openapi_core/validation/request/validators.py +++ b/openapi_core/validation/request/validators.py @@ -11,6 +11,7 @@ from openapi_core.schema.parameters.exceptions import ( ) from openapi_core.schema.paths.exceptions import InvalidPath from openapi_core.schema.request_bodies.exceptions import MissingRequestBody +from openapi_core.schema.schemas.enums import UnmarshalContext from openapi_core.schema.servers.exceptions import InvalidServer from openapi_core.security.exceptions import SecurityError from openapi_core.unmarshalling.schemas.exceptions import ( @@ -23,6 +24,8 @@ from openapi_core.validation.request.datatypes import ( from openapi_core.validation.util import get_operation_pattern +_CONTEXT = UnmarshalContext.REQUEST + class RequestValidator(object): def __init__( diff --git a/openapi_core/validation/response/validators.py b/openapi_core/validation/response/validators.py index 241e8d9..8e93057 100644 --- a/openapi_core/validation/response/validators.py +++ b/openapi_core/validation/response/validators.py @@ -6,6 +6,7 @@ from openapi_core.schema.media_types.exceptions import InvalidContentType from openapi_core.schema.responses.exceptions import ( InvalidResponse, MissingResponseContent, ) +from openapi_core.schema.schemas.enums import UnmarshalContext from openapi_core.schema.servers.exceptions import InvalidServer from openapi_core.unmarshalling.schemas.exceptions import ( UnmarshalError, ValidateError, @@ -13,6 +14,8 @@ from openapi_core.unmarshalling.schemas.exceptions import ( from openapi_core.validation.response.datatypes import ResponseValidationResult from openapi_core.validation.util import get_operation_pattern +_CONTEXT = UnmarshalContext.RESPONSE + class ResponseValidator(object): @@ -73,6 +76,7 @@ class ResponseValidator(object): try: media_type = operation_response[response.mimetype] + except InvalidContentType as exc: return None, [exc, ]