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.
getPetById, addPet)Latest master
If anyone wants to work on this, please reply to let us know.
Hmm, has this been completed by #1470 ?
I keep running into an error when starting the generated aiohttp Python server: :thinking:
~/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'
Yes, should be completed by #1470
cc @Jyhess
@gaborigloi thanks for this report. I missed to generate __init__.py.
I will fix it asap.
@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.
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.
Most helpful comment
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
basePathin a v2 specification or when using openapi v3 (which does not seem to havebasePath):Realized that the reason for this is that in connexion
self._only_one_apiwas false. When calling theconnexion.AioHttpAppconstructor in the generated server, theonly_one_api=Falseargument 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.