Skip to content

madre/aiohttp_apiset

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aiohttp_apiset

image

image

Package to build routes using swagger specification.

Extends specification with directives $include, $view and $handler.

Usecase

$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')

Setup to application

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)

About

Package to build routes using swagger specification

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%