aiohttp-swagger
aiohttp-swagger copied to clipboard
Version 1.0.7. setup_swagger doesn't work
Hi,
Versions: python==3.7.3 aiohttp==3.5.4 aiohttp-swagger==1.0.7
If I try to run examples from https://aiohttp-swagger.readthedocs.io/en/latest/quick_start.html, it doesn't work. Example:
>from aiohttp_swagger import *
>async def ping(request):
... """
... ---
... description: This end-point allow to test that service is up.
... tags:
... - Health check
... produces:
... - text/plain
... responses:
... "200":
... description: successful operation. Return "pong" text
... "405":
... description: invalid HTTP Method
... """
... return web.Response(text="pong")
...
>app = web.Application()
>app.router.add_route('GET', "/ping", ping)
<ResourceRoute [GET] <PlainResource /ping> -> <function ping at 0x1066a6268>
>setup_swagger(app)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/aiohttp_swagger/__init__.py", line 65, in setup_swagger
security_definitions=security_definitions,
File "/usr/local/lib/python3.7/site-packages/aiohttp_swagger/helpers/builders.py", line 139, in generate_doc_from_each_end_point
end_point_doc = _build_doc_from_func_doc(route)
File "/usr/local/lib/python3.7/site-packages/aiohttp_swagger/helpers/builders.py", line 43, in _build_doc_from_func_doc
if issubclass(route.handler, web.View) and route.method == METH_ANY:
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/abc.py", line 143, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class
I can confirm this after testing the most recent version just published today to PyPI.
Same issue is with 1.0.6, only 1.0.5 works for me
I’m sorry. I have not time to check this issue. Can anyone help me?
I have same issue :-(
Also, this requires to be merged to pass tests due to a sub_app issue. https://github.com/cr0hn/aiohttp-swagger/pull/69
#71
I just merged some PR that aims to fix this issues in version 1.0.8.
Thank you @cr0hn, 1.0.8 is working ok for me, even with security definitions
So, there seems to be issue with swagger generation, its not getting properly HTTP method from function. Even if method is PUT, swagger is generated with GET.
So, there seems to be issue with swagger generation, its not getting properly HTTP method from function. Even if method is PUT, swagger is generated with GET.
Yes, here is a fix for that - https://github.com/cr0hn/aiohttp-swagger/pull/72