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

Does not working class based views #72

Open
ALeksandr-Fuze opened this issue Nov 22, 2019 · 7 comments
Open

Does not working class based views #72

ALeksandr-Fuze opened this issue Nov 22, 2019 · 7 comments

Comments

@ALeksandr-Fuze
Copy link

ALeksandr-Fuze commented Nov 22, 2019

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
@thijstriemstra
Copy link

thijstriemstra commented Dec 1, 2019

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

@ALeksandr-Fuze
Copy link
Author

ALeksandr-Fuze commented Dec 2, 2019

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.

@ALeksandr-Fuze
Copy link
Author

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

@CrazySky2121
Copy link

+1

not working for

@request_schema(SchemaPost)
@response_schema(SchemaResp)
async def post(self):
    ...

@maximdanilchenko
Copy link
Owner

As ALeksandr-Fuze mentioned it works only for web.View classes for now. I will make a fix to support your case.

@allyo-dmytro-smyk
Copy link

@maximdanilchenko +1 for this

@CrazySky2121
Copy link

Hello guys! Do you have any ETA for this feature?

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

No branches or pull requests

5 participants