aiohttp.web OpenAPI 3 schema first server applications.
Project description
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.
Works on Python 3.6+
Works with aiohttp.web 3.6+
BSD licensed
Source, issues, and pull requests on GitHub
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
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.1.3.tar.gz
.
File metadata
- Download URL: rororo-2.1.3.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.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6582d9489686169df4e3a2de10ce95fe153010927d20fca65fe44105b1cee09 |
|
MD5 | 33f9fbfb6cafa7050d13b0e57b2db7ec |
|
BLAKE2b-256 | 9df9f0bed81cf0a5624686d1917b11e118a4fc8dd81604cfa811afddc0002bb1 |
Provenance
File details
Details for the file rororo-2.1.3-py3-none-any.whl
.
File metadata
- Download URL: rororo-2.1.3-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.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17cd0abdbb9514ad2c37f691f63d7466ee87c869cf37e6ebdab041facd3e78da |
|
MD5 | 4dfb0c8e1cb729792f2902b55beb0336 |
|
BLAKE2b-256 | 6b3b68b0024361a2f0a3d587d5ec4a473fa34fb7a7eb037b913e26239eb59250 |