Skip to main content

aiohttp.web OpenAPI 3 schema first server applications.

Project description

CI Workflow pre-commit black Latest Version Python versions BSD License Coverage Documentation

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

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

Quick Start

rororo relies on valid OpenAPI 3 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:
    return setup_openapi(
        web.Application(),
        Path(__file__).parent / "openapi.yaml",
        operations,
        server_url="/api",
    )

Schema First Approach

Unlike other popular Python OpenAPI 3 solutions, such as Django REST Framework, FastAPI, flask-apispec, or aiohttp-apispec rororo requires you to provide valid OpenAPI 3 schema first. This makes rororo similar to connexion, pyramid_openapi3 and other schema first libraries.

Class Based Views

rororo supports class based views as well. Todo-Backend example illustrates how to use class based views for OpenAPI 3 servers.

In snippet below, rororo expects that OpenAPI 3 schema contains operation ID UserView.get,

@operations.register
class UserView(web.View):
    async def get(self) -> web.Response:
        ...

More Examples

Check examples folder to see other examples on how to build aiohttp.web OpenAPI 3 server applications.

Project details


Download files

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

Source Distribution

rororo-2.1.2.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

rororo-2.1.2-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file rororo-2.1.2.tar.gz.

File metadata

  • Download URL: rororo-2.1.2.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for rororo-2.1.2.tar.gz
Algorithm Hash digest
SHA256 fd00986bc7165107a2c608a37ce1b2c6678a250253d89d24b6008433869255b1
MD5 dbbe7a748bfe448b389575627dc5d750
BLAKE2b-256 94d49be52de08414020ad614f33df8ff8ca65d79a168b11ec3d7ddf7a91cb1d2

See more details on using hashes here.

Provenance

File details

Details for the file rororo-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: rororo-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for rororo-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a40adc39fb4be80b821731800a385a57c3c72fc8c1171cf70d736ed2789712de
MD5 f99b9adfb2b57325b6f84024603424bf
BLAKE2b-256 1e085eeacfda4237022291f834a751e22257fac37299b1857f65c340eccd29d7

See more details on using hashes here.

Provenance

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