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

Error running python-flask server generated with openapi-generator-cli-3.0.0.jar. #323

Closed
fjd1234 opened this issue Jun 15, 2018 · 10 comments · Fixed by #1066
Closed

Error running python-flask server generated with openapi-generator-cli-3.0.0.jar. #323

fjd1234 opened this issue Jun 15, 2018 · 10 comments · Fixed by #1066

Comments

@fjd1234
Copy link

fjd1234 commented Jun 15, 2018

I've generated python-flask SDK from petstore.yaml and hit the run time error summarized below. This worked fine with the swager-codegen and it seems "openapi" components is not found. It used to be "swagger". Maybe I'm missing some plugin or need a newer python? Any suggestions?

I've attached the complete backtrace.

Thanks
Frank

Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/swagger_spec_validator/common.py", line 24, in wrapper
return method(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/swagger_spec_validator/validator20.py", line 141, in validate_json
cls=Draft4Validator,
File "/usr/lib/python3.5/site-packages/swagger_spec_validator/ref_validators.py", line 53, in validate
instance_cls(schema, *args, **kwargs).validate(instance)
File "/usr/lib/python3.5/site-packages/jsonschema/validators.py", line 130, in validate
raise error
jsonschema.exceptions.ValidationError: 'components', 'openapi', 'servers' do not match any of the regexes: '^x-'

Suggest a fix/enhancement

petstore_flask.txt

@ackintosh
Copy link
Contributor

@fjd1234 Thanks for reporting this issue.

I've also tried to run python-flask stub (latest master) and got similar errors you reported.

$ cd openapi-generator
$ bin/python-flask-petstore-python2.sh
$ cd samples/server/petstore/flaskConnexion-python2/
$ pip install -r requirements.txt
$ python -m openapi_server

Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)

...
...
...

<ValidationError: "'swagger' is a required property">)

It may caused by the two stuff below:

@ackintosh
Copy link
Contributor

@cbornet
Copy link
Member

cbornet commented Jun 18, 2018

Indeed, we generate an OAIv3 yaml but flask-connexion doesn't support it yet.
A solution would be to have a mustache tag that contains a v2 version of the spec.

@fjd1234
Copy link
Author

fjd1234 commented Aug 3, 2018

So the issue seems to be that connexion doesn't support openapi v3 and a suggested solution would be to use a mustache tag that conatains v2 version. How would I do this? I'd like to use this codegen to generate python-flask code for v3 specs.

Thanks
Frank

@abdullin
Copy link

Still the same error with 3.2.2 of the generator. I couldn't find any documentation on how to make openapi generator work with python-flask with any version of the spec.

To avoid confusion, I would propose to remove "python-flask" from the list of the generators on the home page.

@wheelsandmetal
Copy link
Contributor

I would also like the ability to generate a OAIv2/Swagger v2 spec until such a time as connexion can fully support v3

@wing328
Copy link
Member

wing328 commented Sep 1, 2018

Here is the PR to support OpenAPI spec v3 in connexion: spec-first/connexion#621

@cbornet
Copy link
Member

cbornet commented Sep 18, 2018

The PR has been merged and will be part of connexion 2.0 : https://github.com/zalando/connexion/milestone/10

cbornet added a commit to cbornet/openapi-generator that referenced this issue Sep 19, 2018
Use the dev-2.0 git branch of flask connexion to fix the generator.
This is not ideal but better than a generator not working at all.

Fix OpenAPITools#323
wing328 pushed a commit that referenced this issue Sep 20, 2018
Use the dev-2.0 git branch of flask connexion to fix the generator.
This is not ideal but better than a generator not working at all.

Fix #323
@wing328
Copy link
Member

wing328 commented Sep 20, 2018

UPDATE: @cbornet has made a fix (workaround) to the Python Flask generator before connexion 2.0 is officially released.

Please give it a try by using the SNAPSHOT version or the docker image.

We'll close this issue once we update Python Flask generator to use connexion 2.0 stable release.

@wing328 wing328 reopened this Sep 20, 2018
jaumard pushed a commit to jaumard/openapi-generator that referenced this issue Sep 21, 2018
Use the dev-2.0 git branch of flask connexion to fix the generator.
This is not ideal but better than a generator not working at all.

Fix OpenAPITools#323
cbornet added a commit to cbornet/openapi-generator that referenced this issue Nov 5, 2018
@wing328
Copy link
Member

wing328 commented Nov 7, 2018

The Python flask generator has been updated to use flask-connexion 2.0.0 stable version. Please pull the latest master to give it a try.

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this issue Feb 27, 2019
Use the dev-2.0 git branch of flask connexion to fix the generator.
This is not ideal but better than a generator not working at all.

Fix OpenAPITools#323
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this issue Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants