Package to build routes using swagger specification.
Extends specification with directives $include, $view and $handler.
Handler:
from aiohttp import web
async def handler(request):
return web.json_response(
{'test': 'Hello'}
)
Swagger spec:
swagger: '2.0'
basePath: /api/1
paths:
/hello:
get:
$handler: mymodule.handler
summary: and other not required for working route
Equal:
app.router.add_route(
'GET',
'/api/1/hello',
handler,
name='mymodule.handler')
Create router:
from aiohttp_apiset import SwaggerRouter
router = SwaggerRouter(
'data/root.yaml',
search_dirs=['routes'])
Setup to application:
router.setup(app)
or use as router:
Application(router=router)