swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
I generated a client to consume an API. One of the endpoints returns an octet-stream of a zipped file with .zip extension. When receiving this file, I get the following error trace. I get that this is to do with encoding, but I have no idea how to make the codegen generate code that works. When I try chardet it says {'encoding': None, 'confidence': 0.0, 'language': None}. When I fetch the report in Postman, I can save the raw response as a zip file and extract a csv file with no issues.
File "/home/user/dev/my_sdk/api_client.py", line 328, in call_api
return self.__call_api(resource_path, method,
File "/home/user/dev/my_sdk/api_client.py", line 156, in __call_api
response_data = self.request(
File "/home/user/dev/my_sdk/api_client.py", line 350, in request
return self.rest_client.GET(url,
File "/home/user/dev/my_sdk/rest.py", line 257, in GET
return self.request("GET", url,
File "/home/user/dev/my_sdk/rest.py", line 226, in request
r.data = r.data.decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 10: invalid start byte
I think this is a file that needs to be saved without decoding. Can I generate a client that does that, or do I need to set _preload_content to False, and handle it all manually?
Description
I generated a client to consume an API. One of the endpoints returns an octet-stream of a zipped file with .zip extension. When receiving this file, I get the following error trace. I get that this is to do with encoding, but I have no idea how to make the codegen generate code that works. When I try chardet it says {'encoding': None, 'confidence': 0.0, 'language': None}. When I fetch the report in Postman, I can save the raw response as a zip file and extract a csv file with no issues.
Swagger-codegen version
3.0.30
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli.jar generate \ -i openapi-spec.yaml \ -l python \ -o generated_code \ -c config.json
Steps to reproduce
Use the generated client to request the zip file, and you get the error
Related issues/PRs
Suggest a fix/enhancement