aiohttp-swagger icon indicating copy to clipboard operation
aiohttp-swagger copied to clipboard

Version 1.0.7. setup_swagger doesn't work

Open vkropotko opened this issue 5 years ago • 10 comments

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

vkropotko avatar Jul 17 '19 14:07 vkropotko

I can confirm this after testing the most recent version just published today to PyPI.

jaredvacanti avatar Jul 17 '19 17:07 jaredvacanti

Same issue is with 1.0.6, only 1.0.5 works for me

palko444 avatar Jul 17 '19 20:07 palko444

I’m sorry. I have not time to check this issue. Can anyone help me?

cr0hn avatar Jul 17 '19 20:07 cr0hn

I have same issue :-(

sirkonst avatar Jul 18 '19 06:07 sirkonst

Also, this requires to be merged to pass tests due to a sub_app issue. https://github.com/cr0hn/aiohttp-swagger/pull/69

vkropotko avatar Jul 18 '19 13:07 vkropotko

#71

vkropotko avatar Jul 18 '19 13:07 vkropotko

I just merged some PR that aims to fix this issues in version 1.0.8.

cr0hn avatar Jul 18 '19 13:07 cr0hn

Thank you @cr0hn, 1.0.8 is working ok for me, even with security definitions

palko444 avatar Jul 18 '19 14:07 palko444

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.

palko444 avatar Jul 19 '19 08:07 palko444

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

vkropotko avatar Jul 19 '19 10:07 vkropotko