Forum Discussion

chaz8705's avatar
chaz8705
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.

  • 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 "https://api.swaggerhub.com/apis/sirJames/sirJamesPetstore/1.0.0?json" -l python -o C:\python

     

    You can download the swagger-codegen-cli version 2.2.3 jar file from https://mvnrepository.com/artifact/io.swagger/swagger-codegen-cli/2.2.3

     

    Regards,

    Marcus

    SmartBear Support