Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PYTHON] API clients generated are invalid #10079

Closed
nlarusstone opened this issue Mar 3, 2020 · 6 comments · Fixed by swagger-api/swagger-codegen-generators#627
Closed

[PYTHON] API clients generated are invalid #10079

nlarusstone opened this issue Mar 3, 2020 · 6 comments · Fixed by swagger-api/swagger-codegen-generators#627
Milestone

Comments

@nlarusstone
Copy link

Description

When generating the python clients for my swagger, I get import errors when trying to use them. Specifically I see the following error:

    if 'model_image_path' in params:
     ^
IndentationError: expected an indented block

Which is due to the fact that the generated code looks like the following:

        if 'name' in params:
              # noqa: E501
        if 'model_image_path' in params:
              # noqa: E501

Note that my swagger.json was autogenerated by the flask_restplus package: https://github.com/noirbizarre/flask-restplus

Swagger-codegen version

Version 3.0.16

~ $ swagger-codegen version
16:15:45.291 [main] DEBUG io.swagger.codegen.v3.cli.SwaggerCodegen - there are not options for command 'langs'
16:15:45.294 [main] DEBUG io.swagger.codegen.v3.cli.SwaggerCodegen - there are not options for command 'version'
3.0.16
Swagger declaration file content or url

https://gist.github.com/nlarusstone/a79a12b025900d9755dc0abf58b5a040

Command line used for generation
swagger-codegen generate -i swagger.json -l python -o /tmp/test
Steps to reproduce

Run swagger codegen on the swagger.json. (see above for command)
Create fresh virtualenv
Install swagger client package
Try to import swagger client from within a python shell

cd /tmp/test
mkvirtualenv clean
python setup.py install
python -c "import swagger_client"
Related issues/PRs

Couldn't find any

Suggest a fix/enhancement

It seems like the generated code is syntactically invalid python and that should be rectified. I don't know enough about the package to suggest how or where that would occur.

@mtripoli
Copy link

mtripoli commented Mar 4, 2020

I confirm the same issue with the latest swagger-codegen version, 3.0.18

@nlarusstone
Copy link
Author

This seems to work fine with version 3.0.11

@HugoMario
Copy link
Contributor

thanks for reporting this issue, it's been fixed with swagger-codegen-generators#627

@H0r53
Copy link

H0r53 commented Mar 25, 2020

@HugoMario - is this fix only in the current master branch and not the latest stable releases (ie: 3.0.18)? I tried using swagger-codegen via brew and the 3.0.18 jar and it still exists.

@HugoMario
Copy link
Contributor

thanks @H0r53 for letting me know, i'll check and apply fix on v3

@HugoMario
Copy link
Contributor

sorry @H0r53 , i got confuse, yea. these change were merged after 3.0.18 release, so they'll be added to 3.0.19

@HugoMario HugoMario added this to the v3.0.19 milestone Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants