Forum Discussion

chaz8705's avatar
New Member
7 years ago

Python codegen instance of incorrect indentation in `ApiClient.sanitize_for_serialization`.

The python code gen has an instance of incorrect indentation that is causing all API requests to fail.


In `api_client.ApiClient.sanitize_for_serialization`, the block of code that handles the case when `obj` is a dictionary is indented too far. Since python is whitespace sensitive, this causes this block to be scoped under the preceding if block, meaning it never runs. Execution falls off the edge of the function, resulting in a return value of None, which of course immediately throws an exception the second the value is accessed.

1 Reply

  • Hi,


    I have reproduced this issue in Swaggerhub and opened a bug for it.  As a workaround for now please manually correct the indentation until this issue is fixed.  Also as an alternative you can use the swagger-codegen-cli version 2.2.3 on the command line which generates the correct indentation for this issue.  Below is an example of usage to generate the Python client.


    java -jar swagger-codegen-cli.jar generate -i "" -l python -o C:\python


    You can download the swagger-codegen-cli version 2.2.3 jar file from




    SmartBear Support