OpenAPI 3 schema support for aiohttp.web applications.
Project description
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.0rc1
or,
poetry add rororo==2.0.0rc1
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
Class Based Views
rororo supports class based views as well. Todo-Backend example illustrates how to use class based views for OpenAPI handlers.
In snippet below, rororo expects that OpenAPI 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 use OpenAPI 3 schemas with aiohttp.web applications.
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
Built Distribution
File details
Details for the file rororo-2.0.0rc1.tar.gz
.
File metadata
- Download URL: rororo-2.0.0rc1.tar.gz
- Upload date:
- Size: 35.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15ee93825bd97ac72e157840b59d0738ae82a469ea77d60447054e2065790652 |
|
MD5 | 655aa8eed36d8baac77bee81cec67de8 |
|
BLAKE2b-256 | a492a3d8fbd5b38b02a401125a42147fca7495ca8d70499ad112939d225fca18 |
Provenance
File details
Details for the file rororo-2.0.0rc1-py3-none-any.whl
.
File metadata
- Download URL: rororo-2.0.0rc1-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0802bfaf55ed6c23b702056b20fefdfb790aadd2e778a7d2ddd06be20dcc3a5 |
|
MD5 | 15e22a9ccd1900c02584c3f726686fe7 |
|
BLAKE2b-256 | 37d345a480d0b4e51533d9a33e11017fbb66918ac21515a576adda3ebe5b49c4 |