66
77from openapi_core .schema .protocols import SuportsGetAll
88from openapi_core .schema .protocols import SuportsGetList
9+ from openapi_core .schema .types import pick_style_type
910
1011
1112def split (value : str , separator : str = "," , step : int = 1 ) -> List [str ]:
@@ -31,7 +32,7 @@ def delimited_loads(
3132) -> Any :
3233 value = location [name ]
3334
34- explode_type = (explode , schema_type )
35+ explode_type = (explode , pick_style_type ( schema_type ) )
3536 if explode_type == (False , "array" ):
3637 return split (value , separator = delimiter )
3738 if explode_type == (False , "object" ):
@@ -51,25 +52,26 @@ def matrix_loads(
5152 schema_type : str | list [str ],
5253 location : Mapping [str , Any ],
5354) -> Any :
55+ structural_type = pick_style_type (schema_type )
5456 if explode == False :
5557 m = re .match (rf"^;{ name } =(.*)$" , location [f";{ name } " ])
5658 if m is None :
5759 raise KeyError (name )
5860 value = m .group (1 )
5961 # ;color=blue,black,brown
60- if schema_type == "array" :
62+ if structural_type == "array" :
6163 return split (value )
6264 # ;color=R,100,G,200,B,150
63- if schema_type == "object" :
65+ if structural_type == "object" :
6466 return dict (map (split , split (value , step = 2 )))
6567 # .;color=blue
6668 return value
6769 else :
6870 # ;color=blue;color=black;color=brown
69- if schema_type == "array" :
71+ if structural_type == "array" :
7072 return re .findall (rf";{ name } =([^;]*)" , location [f";{ name } *" ])
7173 # ;R=100;G=200;B=150
72- if schema_type == "object" :
74+ if structural_type == "object" :
7375 value = location [f";{ name } *" ]
7476 return dict (
7577 map (
@@ -91,23 +93,24 @@ def label_loads(
9193 schema_type : str | list [str ],
9294 location : Mapping [str , Any ],
9395) -> Any :
96+ structural_type = pick_style_type (schema_type )
9497 if explode == False :
9598 value = location [f".{ name } " ]
9699 # .blue,black,brown
97- if schema_type == "array" :
100+ if structural_type == "array" :
98101 return split (value [1 :])
99102 # .R,100,G,200,B,150
100- if schema_type == "object" :
103+ if structural_type == "object" :
101104 return dict (map (split , split (value [1 :], separator = "," , step = 2 )))
102105 # .blue
103106 return value [1 :]
104107 else :
105108 value = location [f".{ name } *" ]
106109 # .blue.black.brown
107- if schema_type == "array" :
110+ if structural_type == "array" :
108111 return split (value [1 :], separator = "." )
109112 # .R=100.G=200.B=150
110- if schema_type == "object" :
113+ if structural_type == "object" :
111114 return dict (
112115 map (
113116 partial (split , separator = "=" ),
@@ -124,7 +127,7 @@ def form_loads(
124127 schema_type : str | list [str ],
125128 location : Mapping [str , Any ],
126129) -> Any :
127- explode_type = (explode , schema_type )
130+ explode_type = (explode , pick_style_type ( schema_type ) )
128131 # color=blue,black,brown
129132 if explode_type == (False , "array" ):
130133 return split (location [name ], separator = "," )
@@ -159,12 +162,13 @@ def simple_loads(
159162 location : Mapping [str , Any ],
160163) -> Any :
161164 value = location [name ]
165+ structural_type = pick_style_type (schema_type )
162166
163167 # blue,black,brown
164- if schema_type == "array" :
168+ if structural_type == "array" :
165169 return split (value , separator = "," )
166170
167- explode_type = (explode , schema_type )
171+ explode_type = (explode , structural_type )
168172 # R,100,G,200,B,150
169173 if explode_type == (False , "object" ):
170174 return dict (map (split , split (value , separator = "," , step = 2 )))
@@ -204,7 +208,7 @@ def deep_object_loads(
204208 schema_type : str | list [str ],
205209 location : Mapping [str , Any ],
206210) -> Any :
207- explode_type = (explode , schema_type )
211+ explode_type = (explode , pick_style_type ( schema_type ) )
208212
209213 if explode_type != (True , "object" ):
210214 raise ValueError ("not available" )
0 commit comments