• Stars
    star
    105
  • Rank 328,196 (Top 7 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created about 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

rororo

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")
        email = context.parameters.query.get(
            "email", "[email protected]"
        )
        return web.json_response(
            {"message": f"Hello, {name}!", "email": email}
        )


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.

More Repositories

1

Flask-And-Redis

Simple as dead support of Redis database for Flask applications
Python
84
star
2

Flask-Dropbox

Dropbox Python SDK support for Flask applications
Python
64
star
3

aiohttp-middlewares

Collection of useful middlewares for aiohttp.web applications.
Python
50
star
4

tddspry

Collection of testcases and helpers to test Django projects and applications with nose and twill libraries.
Python
37
star
5

django-mediafiles

Django media files manager
Python
34
star
6

Flask-LazyViews

Register URL routes for Flask application or blueprint in lazy way
Python
28
star
7

kikola

Kikola is a collection of Django's custom context processors, form fields and widgets, middlewares, model fields, reusable apps and template tags.
Python
20
star
8

bootstrapper

Bootstrap Python projects or libraries with virtualenv and pip
Python
10
star
9

scm-up-all

Python script to fast update all SCMs (Bazaar, Darcs, Git, Git SVN, Mercurial, Subversion) directories
Python
8
star
10

docker-python

Add poetry, pre-commit, and other dev tools for official Python slim bullseye Docker image.
Dockerfile
8
star
11

djake

djake = Django + make, where make is your manage.py script
Shell
5
star
12

badabump

Manage changelog and bump project version number using conventional commits from latest git tag. Support Python & JavaScript projects and CalVer & SemVer schemas. Designed to run at GitHub Actions.
Python
5
star
13

readthestuff

Read the Stuff or yet another Google Reader alternative built on top of Python
Python
5
star
14

setman

Settings manager for Python web-apps and projects. Another?
Python
3
star
15

pre-commit-run-hook-entry

Run pre-commit hook entry. Allow to run pre-commit hooks for text editor formatting / linting needs.
Python
2
star
16

watracest

Which Rage Face Are You?
JavaScript
1
star