diff --git a/sdks/python/dropbox_sign/api_client.py b/sdks/python/dropbox_sign/api_client.py index 800e07ad5..509df36d4 100644 --- a/sdks/python/dropbox_sign/api_client.py +++ b/sdks/python/dropbox_sign/api_client.py @@ -302,6 +302,8 @@ def response_deserialize( try: if response_type == "bytearray": return_data = response_data.data + elif response_type == "io.IOBase": + return_data = self.__bytearray_to_iobase(response_data) elif response_type == "file": return_data = self.__deserialize_file(response_data) elif response_type is not None: @@ -691,6 +693,13 @@ def __deserialize_file(self, response): return path + def __bytearray_to_iobase(self, response): + """Convert bytearray to io.IOBase""" + buffer = io.BytesIO() + buffer.write(response.data) + buffer.seek(0) + return buffer + def __deserialize_primitive(self, data, klass): """Deserializes string to primitive type. diff --git a/sdks/python/templates/api_client.mustache b/sdks/python/templates/api_client.mustache index 1ecc9b787..3fd4b3952 100644 --- a/sdks/python/templates/api_client.mustache +++ b/sdks/python/templates/api_client.mustache @@ -318,6 +318,10 @@ class ApiClient: try: if response_type == "bytearray": return_data = response_data.data +{{#useCustomTemplateCode}} + elif response_type == "io.IOBase": + return_data = self.__bytearray_to_iobase(response_data) +{{/useCustomTemplateCode}} elif response_type == "file": return_data = self.__deserialize_file(response_data) elif response_type is not None: @@ -739,6 +743,15 @@ class ApiClient: return path + {{#useCustomTemplateCode}} + def __bytearray_to_iobase(self, response): + """Convert bytearray to io.IOBase""" + buffer = io.BytesIO() + buffer.write(response.data) + buffer.seek(0) + return buffer + + {{/useCustomTemplateCode}} def __deserialize_primitive(self, data, klass): """Deserializes string to primitive type.