mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-22 03:00:10 +00:00
Python 3.5 json binary input deserialization fix
This commit is contained in:
parent
0d0fa524cf
commit
0f7fa5287e
2 changed files with 12 additions and 3 deletions
|
@ -1,9 +1,8 @@
|
||||||
"""OpenAPI core media types models module"""
|
"""OpenAPI core media types models module"""
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from json import loads
|
|
||||||
|
|
||||||
from openapi_core.schema.media_types.exceptions import InvalidMediaTypeValue
|
from openapi_core.schema.media_types.exceptions import InvalidMediaTypeValue
|
||||||
|
from openapi_core.schema.media_types.util import json_loads
|
||||||
from openapi_core.schema.schemas.exceptions import (
|
from openapi_core.schema.schemas.exceptions import (
|
||||||
CastError, ValidateError,
|
CastError, ValidateError,
|
||||||
)
|
)
|
||||||
|
@ -11,7 +10,7 @@ from openapi_core.unmarshalling.schemas.exceptions import UnmarshalError
|
||||||
|
|
||||||
|
|
||||||
MEDIA_TYPE_DESERIALIZERS = {
|
MEDIA_TYPE_DESERIALIZERS = {
|
||||||
'application/json': loads,
|
'application/json': json_loads,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
10
openapi_core/schema/media_types/util.py
Normal file
10
openapi_core/schema/media_types/util.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from json import loads
|
||||||
|
|
||||||
|
from six import binary_type
|
||||||
|
|
||||||
|
|
||||||
|
def json_loads(value):
|
||||||
|
# python 3.5 doesn't support binary input fix
|
||||||
|
if isinstance(value, (binary_type, )):
|
||||||
|
value = value.decode()
|
||||||
|
return loads(value)
|
Loading…
Reference in a new issue