Providing a context whenever unmarshalling objects on Request and Responses

(readOnly and writeOnly applies on to properties)
This commit is contained in:
Pedro Peixoto 2019-07-13 08:51:45 -03:00 committed by Artur Maciag
parent ca369f795a
commit aa95bc5d02
3 changed files with 12 additions and 0 deletions

View file

@ -26,3 +26,8 @@ class SchemaFormat(Enum):
DATETIME = 'date-time'
PASSWORD = 'password'
UUID = 'uuid'
class UnmarshalContext(Enum):
REQUEST = 'request'
RESPONSE = 'response'

View file

@ -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__(

View file

@ -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, ]