Skip to main content

Build routes using swagger specification

Project description Coverage Code style: ruff Documentation Status Hatch project

Package to build routes and validate request using swagger specification 2.0.


  • Building of the routing from specification swagger

  • Using inclusions other specifications with concatenate url

  • Optional output of the resulting specification and view embed swagger-ui

  • Advanced router with TreeResource

  • Extract specify parameters from request and validate with jsonschema

  • Serialize data as response with middleware


Package aiohttp_apiset allows supports several strategies:

  • The foreign specification. When the specification is made and maintained by another team.

  • The specification in the code. When the fragments of specification are placed in the docstrings.

  • Mixed strategy. When routing are located in the specification files and operations are described in the docstrings.


async def handler(request, pet_id):
    tags: [Pet]
    description: Info about pet
      - name: pet_id
        in: path
        type: integer
        minimum: 0
        description: OK
        description: Validation error
        description: Not found
    pet = await db.pets.find(pet_id)

    if not pet:
        return {'status': 404, 'msg': 'Not Found'}

    return {
        'pet': pet,  # dict serialized inside jsonify

def main():
    router = SwaggerRouter(
    router.add_get('/pets/{pet_id}', handler=handler)

    app = web.Application(


Is now available in the swagger-ui to the address http://localhost:8080/swagger/. Available both branch swagger-ui. For use branch 3.x visit http://localhost:8080/swagger/?version=3

Examples: examples


Check code:

hatch run lint:all

Format code:

hatch run lint:fmt

Run tests:

hatch run pytest

Run tests with coverage:

hatch run cov

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp_apiset-0.9.16.tar.gz (8.6 MB view hashes)

Uploaded Source

Built Distribution

aiohttp_apiset-0.9.16-py3-none-any.whl (8.7 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page