aiohttp-swagger
aiohttp-swagger copied to clipboard
docstring parsing doesn't work if you have inheritance in class based view
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__'