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

docstring parsing doesn't work if you have inheritance in class based view #93

Open
well2life opened this issue Aug 10, 2020 · 0 comments

Comments

@well2life
Copy link

well2life commented Aug 10, 2020

I'm trying to use inheritance in my class based view:

from aiohttp import web
from aiohttp_swagger3 import SwaggerDocs, SwaggerUiSettings


class BaseApi(web.View):
    async def get(self):
        return web.json_response(data={'called_method': 'GET'})

    async def post(self):
        return web.json_response(data={'called_method': 'POST'})

    async def put(self):
        return web.json_response(data={'called_method': 'PUT'})

    async def patch(self):
        return web.json_response(data={'called_method': 'PATCH'})


class SomeApi(BaseApi):
    def some_stuff(self):
        pass

    async def get(self):
        """
        ---
        summary: Some GET method
        responses:
          '200':
            description: OK.
        """
        self.some_stuff()
        return await super().get()


app = web.Application()

swagger = SwaggerDocs(
        app,
        swagger_ui_settings=SwaggerUiSettings(path="/api/v1.0.0/docs/"),
        title="Proto",
        version="1.0.0",
    )

swagger.add_routes([
        web.view('/api/some_api', SomeApi, name="some_api"),
    ])

web.run_app(app, host="127.0.0.1")

But I receive next exception:

File "lib/site-packages/aiohttp_swagger3/swagger_route.py", line 36, in _get_fn_parameters
    if func.__closure__ is None:
AttributeError: type object 'SomeApi' has no attribute '__closure__'
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

1 participant