Open mike-res opened 8 months ago
I switched to using swagger-codegen-cli-2.4.39.jar so that I could generate client code automatically as part of our CI/CD flow, and the issues cited above are present in swagger-codegen-cli-2.4.39.jar .. hopefully that fills in some of the blanks for which versions of the code generator have this issue..
Description
The code in python-client/swagger_client/api_client.py contains code for the ApiClient class.
I have found that two methods in the generated ApiClient class need to be patched in order ot ensure reliable operation:
ApiClient::__deserialize_primitive(self, data, klass)
, there are only exception handler cases for two exception types, UnicodeEncodeError and TypeError. I have found it necessary to add a third case, to handle "all other errors". The code that I used for this is the following (the last two lines are the change).ApiClient::__deserialize_model(self, data, klass)
: When a response calls to a model in order to deserialize it, theApiClient
should add its self.configuration to the kwargs that it passes to the constructor of the object that handles the deserialization. For example, this will allow the model to inherit theclient_side_validation
property from the Config instance that was used to instantiate theApiClient
. This is useful, for example, if one wants to setConfiguration.client_side_validation
to false in order to inhibit strict type-checking. I nade the following change in ApiClient::__deserialize_model in order to have deserialixation models inherit the ApiClient's Config instance.Swagger-codegen version
Unclear which version ie being used. I was using https://editor.swagger.io/) and https://editor-next.swagger.io/. Both of the online editors have the same issue.
Swagger declaration file content or url
No
swagger: '2.0'
code provided .. this issue is present in any code that the online python client generator produces.Command line used for generation
used online editors (https://editor.swagger.io/) and https://editor-next.swagger.io/)
Steps to reproduce
Thiese issues are present in any python client produced by either https://editor.swagger.io/) and https://editor-next.swagger.io/.
Related issues/PRs
Suggest a fix/enhancement
Examples of preferred resulting code in the
ApiClient::__deserialize_primitive(self, data, klass)
andApiClient::__deserialize_model(self, data, klass)
methods appear above.