Skip to content

Commit aa95bc5

Browse files
phrfpeixotop1c2u
authored andcommitted
Providing a context whenever unmarshalling objects on Request and Responses
(readOnly and writeOnly applies on to properties)
1 parent ca369f7 commit aa95bc5

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

openapi_core/schema/schemas/enums.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ class SchemaFormat(Enum):
2626
DATETIME = 'date-time'
2727
PASSWORD = 'password'
2828
UUID = 'uuid'
29+
30+
31+
class UnmarshalContext(Enum):
32+
REQUEST = 'request'
33+
RESPONSE = 'response'

openapi_core/validation/request/validators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
)
1212
from openapi_core.schema.paths.exceptions import InvalidPath
1313
from openapi_core.schema.request_bodies.exceptions import MissingRequestBody
14+
from openapi_core.schema.schemas.enums import UnmarshalContext
1415
from openapi_core.schema.servers.exceptions import InvalidServer
1516
from openapi_core.security.exceptions import SecurityError
1617
from openapi_core.unmarshalling.schemas.exceptions import (
@@ -23,6 +24,8 @@
2324
from openapi_core.validation.util import get_operation_pattern
2425

2526

27+
_CONTEXT = UnmarshalContext.REQUEST
28+
2629
class RequestValidator(object):
2730

2831
def __init__(

openapi_core/validation/response/validators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
from openapi_core.schema.responses.exceptions import (
77
InvalidResponse, MissingResponseContent,
88
)
9+
from openapi_core.schema.schemas.enums import UnmarshalContext
910
from openapi_core.schema.servers.exceptions import InvalidServer
1011
from openapi_core.unmarshalling.schemas.exceptions import (
1112
UnmarshalError, ValidateError,
1213
)
1314
from openapi_core.validation.response.datatypes import ResponseValidationResult
1415
from openapi_core.validation.util import get_operation_pattern
1516

17+
_CONTEXT = UnmarshalContext.RESPONSE
18+
1619

1720
class ResponseValidator(object):
1821

@@ -73,6 +76,7 @@ def _get_data(self, response, operation_response):
7376

7477
try:
7578
media_type = operation_response[response.mimetype]
79+
7680
except InvalidContentType as exc:
7781
return None, [exc, ]
7882

0 commit comments

Comments
 (0)