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.3.0.tar.gz (38.1 kB view details)

Uploaded Source

Built Distribution

rororo-2.3.0-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rororo-2.3.0.tar.gz
  • Upload date:
  • Size: 38.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for rororo-2.3.0.tar.gz
Algorithm Hash digest
SHA256 1f52d39f2b737f03a981330e67800d1aabb11828bd8b5a27a450f452e34c7556
MD5 4f910898b974f354e46f3000208b3076
BLAKE2b-256 3d5a5fef284de0d61075b3fbd3e79b44bc0db023b41572accb4de318765d0217

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: rororo-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for rororo-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45cfab8779df7edf2258086b7660f6155291a01301c88e2239f3b477e7b2592c
MD5 72917ab25b44b2852323e941a36a5e68
BLAKE2b-256 8f7293f78dce6768ad3cc9bdb2acabd5346754922fa5a3028b71f68ffbf06826

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