File tree Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -32,14 +32,14 @@ def deserialize(self, value):
3232 return deserializer (value )
3333
3434 def cast (self , value ):
35- if not self .schema :
36- return value
37-
3835 try :
3936 deserialized = self .deserialize (value )
4037 except ValueError as exc :
4138 raise InvalidMediaTypeValue (exc )
4239
40+ if not self .schema :
41+ return deserialized
42+
4343 try :
4444 return self .schema .cast (deserialized )
4545 except CastError as exc :
Original file line number Diff line number Diff line change @@ -99,14 +99,14 @@ def cast(self, value):
9999 not self .allow_empty_value ):
100100 raise EmptyParameterValue (self .name )
101101
102- if not self .schema :
103- return value
104-
105102 try :
106103 deserialized = self .deserialize (value )
107104 except (ValueError , AttributeError ) as exc :
108105 raise InvalidParameterValue (self .name , exc )
109106
107+ if not self .schema :
108+ return deserialized
109+
110110 try :
111111 return self .schema .cast (deserialized )
112112 except CastError as exc :
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from openapi_core .schema .media_types .exceptions import InvalidMediaTypeValue
14from openapi_core .schema .media_types .models import MediaType
25
36
@@ -7,6 +10,13 @@ def test_empty(self):
710 media_type = MediaType ('application/json' )
811 value = ''
912
13+ with pytest .raises (InvalidMediaTypeValue ):
14+ media_type .cast (value )
15+
16+ def test_no_schema_deserialised (self ):
17+ media_type = MediaType ('application/json' )
18+ value = "{}"
19+
1020 result = media_type .cast (value )
1121
12- assert result == value
22+ assert result == {}
You can’t perform that action at this time.
0 commit comments