aiohttp-apispec
aiohttp-apispec copied to clipboard
Does not working class based views
python 3.8. aiohttp 3.6.2 It does not work class-based views, Swagger shows nothing. When using function style all work correctly.
class SomeView(web.View):
@docs(
tags=["mytag"],
summary="View method summary",
description="View method description",
)
async def post(self) -> web.json_response:
pass
you can use a simple class and route that.
class NewsAPIHandler(object):
@docs(
tags=['news'],
summary='Get news article(s)',
description='Get news article.'
)
@request_schema(GetRequestSchema())
async def get_article(self, request):
pass
Yes, but for the router, I should get a callable Requeste or awaitable stream object. app.router.add_route('*', '/some_api', views. NewsAPIHandler) - will be not work app.router.add_post('/some_api', views.NewsAPIHandler(). get_article) - looks not good and works only for one HTTP method.
Hm... It works if a class was decorated:
@docs(
tags=["mytag"],
summary="View method summary",
description="View method description",
)
class SomeView(web.View):
async def post(self) -> web.json_response:
pass
+1
not working for
@request_schema(SchemaPost)
@response_schema(SchemaResp)
async def post(self):
...
As ALeksandr-Fuze mentioned it works only for web.View classes for now. I will make a fix to support your case.
@maximdanilchenko +1 for this
Hello guys! Do you have any ETA for this feature?