Forum Discussion

RBlack's avatar
RBlack
Occasional Contributor
5 years ago

swagger-codegen-cli-v3 Python response_type='Object' possible bug

I'm using the swaggerapi/swagger-codegen-cli-v3 Docker image to generate Python client code from a simple live API.  However when I use the DefaultApi class in api/default_api.py I get deserialization errors for response_type='Object'.  I resolved / worked around these errors by changing the generated code after the fact with this shell command:

 

# fix what appears to be a bug in the SDK portion of the generated code
sed -i.orig -e "s/response_type='Object'/response_type=object/" ./out/python/api/default_api.py

By SDK portion in the comment I refer to the generated client class that hides the HTTP response details, as per https://github.com/swagger-api/swagger-codegen.   This problem does not occur with api_client.py/ApiClient which one level lower than api/default_api.py/DefaultApi.  

 

By changing the generated code to read response_type=object, the DefaultApi class returns the deserialized data from a GET unchanged, which is what I wanted for my client script.  It no longer trips up over 'Object' which is not a Python type anyway, which is why I think this may be a code generation bug.  

No RepliesBe the first to reply