@@ -66,6 +66,7 @@ class ApiClient:
6666 "date" : datetime .date ,
6767 "datetime" : datetime .datetime ,
6868 "decimal" : decimal .Decimal ,
69+ "UUID" : uuid .UUID ,
6970 "object" : object ,
7071 }
7172 _pool = None
@@ -265,7 +266,7 @@ def response_deserialize(
265266 response_text = None
266267 return_data = None
267268 try :
268- if response_type == "bytearray" :
269+ if response_type in ( "bytearray" , "bytes" ) :
269270 return_data = response_data .data
270271 elif response_type == "file" :
271272 return_data = self .__deserialize_file (response_data )
@@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj):
326327 return obj .isoformat ()
327328 elif isinstance (obj , decimal .Decimal ):
328329 return str (obj )
329-
330330 elif isinstance (obj , dict ):
331- obj_dict = obj
331+ return {key : self .sanitize_for_serialization (val ) for key , val in obj .items ()}
332+
333+ # Convert model obj to dict except
334+ # attributes `openapi_types`, `attribute_map`
335+ # and attributes which value is not None.
336+ # Convert attribute name to json key in
337+ # model definition for request.
338+ if hasattr (obj , "to_dict" ) and callable (getattr (obj , "to_dict" )):
339+ obj_dict = obj .to_dict ()
332340 else :
333- # Convert model obj to dict except
334- # attributes `openapi_types`, `attribute_map`
335- # and attributes which value is not None.
336- # Convert attribute name to json key in
337- # model definition for request.
338- if hasattr (obj , "to_dict" ) and callable (getattr (obj , "to_dict" )): # noqa: B009
339- obj_dict = obj .to_dict ()
340- else :
341- obj_dict = obj .__dict__
342-
343- if isinstance (obj_dict , list ):
344- # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501
345- return self .sanitize_for_serialization (obj_dict )
341+ obj_dict = obj .__dict__
346342
347- return { key : self .sanitize_for_serialization (val ) for key , val in obj_dict . items ()}
343+ return self .sanitize_for_serialization (obj_dict )
348344
349345 def deserialize (self , response_text : str , response_type : str , content_type : Optional [str ]):
350346 """Deserializes response into an object.
@@ -417,6 +413,8 @@ def __deserialize(self, data, klass):
417413 return self .__deserialize_datetime (data )
418414 elif klass is decimal .Decimal :
419415 return decimal .Decimal (data )
416+ elif klass is uuid .UUID :
417+ return uuid .UUID (data )
420418 elif issubclass (klass , Enum ):
421419 return self .__deserialize_enum (data , klass )
422420 else :
0 commit comments