Python 3.5 json binary input deserialization fix

This commit is contained in:
Artur Maciag 2020-01-24 15:37:23 +00:00 committed by p1c2u
parent 0d0fa524cf
commit 0f7fa5287e
2 changed files with 12 additions and 3 deletions

View file

@ -1,9 +1,8 @@
"""OpenAPI core media types models module"""
from collections import defaultdict
from json import loads
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 (
CastError, ValidateError,
)
@ -11,7 +10,7 @@ from openapi_core.unmarshalling.schemas.exceptions import UnmarshalError
MEDIA_TYPE_DESERIALIZERS = {
'application/json': loads,
'application/json': json_loads,
}

View 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)