Skip to content

Commit 0f7fa52

Browse files
committed
Python 3.5 json binary input deserialization fix
1 parent 0d0fa52 commit 0f7fa52

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

openapi_core/schema/media_types/models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
"""OpenAPI core media types models module"""
22
from collections import defaultdict
33

4-
from json import loads
5-
64
from openapi_core.schema.media_types.exceptions import InvalidMediaTypeValue
5+
from openapi_core.schema.media_types.util import json_loads
76
from openapi_core.schema.schemas.exceptions import (
87
CastError, ValidateError,
98
)
109
from openapi_core.unmarshalling.schemas.exceptions import UnmarshalError
1110

1211

1312
MEDIA_TYPE_DESERIALIZERS = {
14-
'application/json': loads,
13+
'application/json': json_loads,
1514
}
1615

1716

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from json import loads
2+
3+
from six import binary_type
4+
5+
6+
def json_loads(value):
7+
# python 3.5 doesn't support binary input fix
8+
if isinstance(value, (binary_type, )):
9+
value = value.decode()
10+
return loads(value)

0 commit comments

Comments
 (0)