mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 03:00:11 +00:00
Providing a context whenever unmarshalling objects on Request and Responses
(readOnly and writeOnly applies on to properties)
This commit is contained in:
parent
ca369f795a
commit
aa95bc5d02
3 changed files with 12 additions and 0 deletions
|
@ -26,3 +26,8 @@ class SchemaFormat(Enum):
|
||||||
DATETIME = 'date-time'
|
DATETIME = 'date-time'
|
||||||
PASSWORD = 'password'
|
PASSWORD = 'password'
|
||||||
UUID = 'uuid'
|
UUID = 'uuid'
|
||||||
|
|
||||||
|
|
||||||
|
class UnmarshalContext(Enum):
|
||||||
|
REQUEST = 'request'
|
||||||
|
RESPONSE = 'response'
|
||||||
|
|
|
@ -11,6 +11,7 @@ from openapi_core.schema.parameters.exceptions import (
|
||||||
)
|
)
|
||||||
from openapi_core.schema.paths.exceptions import InvalidPath
|
from openapi_core.schema.paths.exceptions import InvalidPath
|
||||||
from openapi_core.schema.request_bodies.exceptions import MissingRequestBody
|
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.schema.servers.exceptions import InvalidServer
|
||||||
from openapi_core.security.exceptions import SecurityError
|
from openapi_core.security.exceptions import SecurityError
|
||||||
from openapi_core.unmarshalling.schemas.exceptions import (
|
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
|
from openapi_core.validation.util import get_operation_pattern
|
||||||
|
|
||||||
|
|
||||||
|
_CONTEXT = UnmarshalContext.REQUEST
|
||||||
|
|
||||||
class RequestValidator(object):
|
class RequestValidator(object):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
|
@ -6,6 +6,7 @@ from openapi_core.schema.media_types.exceptions import InvalidContentType
|
||||||
from openapi_core.schema.responses.exceptions import (
|
from openapi_core.schema.responses.exceptions import (
|
||||||
InvalidResponse, MissingResponseContent,
|
InvalidResponse, MissingResponseContent,
|
||||||
)
|
)
|
||||||
|
from openapi_core.schema.schemas.enums import UnmarshalContext
|
||||||
from openapi_core.schema.servers.exceptions import InvalidServer
|
from openapi_core.schema.servers.exceptions import InvalidServer
|
||||||
from openapi_core.unmarshalling.schemas.exceptions import (
|
from openapi_core.unmarshalling.schemas.exceptions import (
|
||||||
UnmarshalError, ValidateError,
|
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.response.datatypes import ResponseValidationResult
|
||||||
from openapi_core.validation.util import get_operation_pattern
|
from openapi_core.validation.util import get_operation_pattern
|
||||||
|
|
||||||
|
_CONTEXT = UnmarshalContext.RESPONSE
|
||||||
|
|
||||||
|
|
||||||
class ResponseValidator(object):
|
class ResponseValidator(object):
|
||||||
|
|
||||||
|
@ -73,6 +76,7 @@ class ResponseValidator(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
media_type = operation_response[response.mimetype]
|
media_type = operation_response[response.mimetype]
|
||||||
|
|
||||||
except InvalidContentType as exc:
|
except InvalidContentType as exc:
|
||||||
return None, [exc, ]
|
return None, [exc, ]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue