Skip to content

Implement aiohttp.web OpenAPI 3 server applications with schema first approach.

License

Notifications You must be signed in to change notification settings

playpauseandstop/rororo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cc21aed · Oct 22, 2019
Oct 22, 2019
Oct 14, 2019
Oct 22, 2019
Oct 22, 2019
Oct 14, 2019
Nov 26, 2015
Jul 2, 2019
Oct 24, 2018
Oct 22, 2019
Oct 22, 2019
Oct 22, 2019
Mar 22, 2019
Mar 24, 2019
Oct 22, 2019
Oct 9, 2019
Oct 22, 2019
Oct 22, 2019
Oct 22, 2019
Oct 14, 2019

Repository files navigation

rororo

CircleCI Latest Version Python versions BSD License Coverage Documentation

OpenAPI 3 schema support for aiohttp.web applications.

As well as bunch other utilities to build effective web applications with Python 3 & aiohttp.web.

  • Works on Python 3.6+
  • BSD licensed
  • Source, issues, and pull requests on GitHub

Important

2.0.0 version still in development. To install it use,

pip install rororo>=2.0.0a3

or,

poetry add rororo^=2.0.0a3

Quick Start

rororo relies on valid OpenAPI schema file (both JSON or YAML formats supported).

Example below, illustrates on how to handle operation hello_world from openapi.yaml schema file.

from pathlib import Path
from typing import List

from aiohttp import web
from rororo import openapi_context, OperationTableDef, setup_openapi


operations = OperationTableDef()


@operations.register
async def hello_world(request: web.Request) -> web.Response:
    with openapi_context(request) as context:
        name = context.parameters.query.get("name", "world")
        return web.json_response({"message": f"Hello, {name}!"})


def create_app(argv: List[str] = None) -> web.Application:
    app = web.Application()
    setup_openapi(
        app,
        Path(__file__).parent / "openapi.yaml",
        operations,
        route_prefix="/api"
    )
    return app

Check examples folder to see other examples on how to use OpenAPI 3 schemas with aiohttp.web applications.