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

Add Python "aiohttp" server generator #1322

Closed
wing328 opened this issue Oct 26, 2018 · 5 comments
Closed

Add Python "aiohttp" server generator #1322

wing328 opened this issue Oct 26, 2018 · 5 comments

Comments

@wing328
Copy link
Member

wing328 commented Oct 26, 2018

Description

We would like to create a Python aiohttp server generator.

Similar to how some other generators (e.g. R, Lua, PowerShell) are created, we will use the reverse engineering process to create the Lisp client generator.

  • create Python aiohttp petstore server samples (implemented at least 2 endpoints to start with: getPetById, addPet)
  • reverse engineer the templates and the generator (Java class)
  • test the auto-generated code and revise the generator, templates
openapi-generator version

Latest master

Suggest a fix/enhancement

If anyone wants to work on this, please reply to let us know.

@gaborigloi
Copy link

Hmm, has this been completed by #1470 ?
I keep running into an error when starting the generated aiohttp Python server: 🤔

~/s/o/s/s/p/python-aiohttp (master|✔) $ python3 -m openapi_server
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/gabori/src/openapi-generator/samples/server/petstore/python-aiohttp/openapi_server/__main__.py", line 3, in <module>
    from . import main
ImportError: cannot import name 'main'

@wing328 wing328 added this to the 4.0.0 milestone Jan 16, 2019
@wing328
Copy link
Member Author

wing328 commented Jan 16, 2019

Yes, should be completed by #1470

cc @Jyhess

@Jyhess
Copy link
Contributor

Jyhess commented Jan 17, 2019

@gaborigloi thanks for this report. I missed to generate init.py.
I will fix it asap.

@wing328
Copy link
Member Author

wing328 commented Jan 18, 2019

@gaborigloi the issue has been fixed with #1933. Please give it another try with the latest master.

@Jyhess thanks for the quick turnaround in fixing the issue.

@wing328 wing328 closed this as completed Jan 18, 2019
@gaborigloi
Copy link

Thanks for the fix @Jyhess. Now it worked fine when using v2 specifications with a basePath.

However I ran into this connexion error when not specifying a basePath in a v2 specification or when using openapi v3 (which does not seem to have basePath):

connexion.exceptions.ConnexionException: aiohttp doesn't allow to set empty base_path ('/'), use non-empty instead, e.g /api

Realized that the reason for this is that in connexion self._only_one_api was false. When calling the connexion.AioHttpApp constructor in the generated server, the only_one_api=False argument should be set to True if there is only one API, to allow specifications with only one API to have an empty/no base path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants