Minimal OpenAPI asynchronous server application
Project description
Home-page: https://github.com/lendingblock/aio-openapi
Maintainer-email: admin@lendingblock.com
License: BSD
Description: # aio-openapi
[![PyPI version](https://badge.fury.io/py/aio-openapi.svg)](https://badge.fury.io/py/aio-openapi)
[![Python versions](https://img.shields.io/pypi/pyversions/aio-openapi.svg)](https://pypi.org/project/aio-openapi)
[![CircleCI](https://circleci.com/gh/lendingblock/aio-openapi.svg?style=svg)](https://circleci.com/gh/lendingblock/aio-openapi)
[![codecov](https://codecov.io/gh/lendingblock/aio-openapi/branch/master/graph/badge.svg)](https://codecov.io/gh/lendingblock/aio-openapi)
Asynchronous web middleware for Rest APIs with PostgreSql Database.
## Installation
```
pip install aio-openapi
```
## Development
Clone the repository and create a virtual environment `venv`.
Install dependencies by running the install script
```
./dev/install.sh
```
To run tests
```
pytest --cov
```
## Features
* Asynchronous web routes with [aiohttp](https://aiohttp.readthedocs.io/en/stable/)
* Data validation, serialization and unserialization with python [dataclasses](https://docs.python.org/3/library/dataclasses.html)
* [OpenApi](https://www.openapis.org/) v 3 auto documentation
* [SqlAlchemy](https://www.sqlalchemy.org/) expression language
* Asynchronous DB interaction with [asyncpg](https://github.com/MagicStack/asyncpg)
* Migrations with [alembic](http://alembic.zzzcomputing.com/en/latest/)
* SqlAlchemy tables as python dataclasses
## Websockets
This library provides a simple distributed websocket utility for creating
websocket remote procedure calls (RPC) and pub/sub.
```python
from aiohttp import web
from openapi.ws import Sockets
app = web.Application()
...
app['web_sockets'] = Sockets(app)
```
### RPC protocol
The RPC protocol has the following structure for incoming messages
```
{
"id": "abc",
"method": "rpc_method_name":
"payload": {
...
}
}
```
The ``id`` is used by clients to link the request with the corresponding response.
The response for an RPC call is eitrher a success
```
{
"id": "abc",
"method": "rpc_method_name":
"result": {
...
}
}
```
or error
```
{
"id": "abc",
"method": "rpc_method_name":
"error": {
...
}
}
```
### Publish/Subscribe
To subscribe to messages, one need to use the ``Subscribe`` mixin with the subscribe RPC handler.
Messages take the form:
```
{
"channel": "channel_name",
"event": "event_name":
"data": {
...
}
}
```
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Utilities
Requires-Python: >=3.6.0
Description-Content-Type: text/markdown
Maintainer-email: admin@lendingblock.com
License: BSD
Description: # aio-openapi
[![PyPI version](https://badge.fury.io/py/aio-openapi.svg)](https://badge.fury.io/py/aio-openapi)
[![Python versions](https://img.shields.io/pypi/pyversions/aio-openapi.svg)](https://pypi.org/project/aio-openapi)
[![CircleCI](https://circleci.com/gh/lendingblock/aio-openapi.svg?style=svg)](https://circleci.com/gh/lendingblock/aio-openapi)
[![codecov](https://codecov.io/gh/lendingblock/aio-openapi/branch/master/graph/badge.svg)](https://codecov.io/gh/lendingblock/aio-openapi)
Asynchronous web middleware for Rest APIs with PostgreSql Database.
## Installation
```
pip install aio-openapi
```
## Development
Clone the repository and create a virtual environment `venv`.
Install dependencies by running the install script
```
./dev/install.sh
```
To run tests
```
pytest --cov
```
## Features
* Asynchronous web routes with [aiohttp](https://aiohttp.readthedocs.io/en/stable/)
* Data validation, serialization and unserialization with python [dataclasses](https://docs.python.org/3/library/dataclasses.html)
* [OpenApi](https://www.openapis.org/) v 3 auto documentation
* [SqlAlchemy](https://www.sqlalchemy.org/) expression language
* Asynchronous DB interaction with [asyncpg](https://github.com/MagicStack/asyncpg)
* Migrations with [alembic](http://alembic.zzzcomputing.com/en/latest/)
* SqlAlchemy tables as python dataclasses
## Websockets
This library provides a simple distributed websocket utility for creating
websocket remote procedure calls (RPC) and pub/sub.
```python
from aiohttp import web
from openapi.ws import Sockets
app = web.Application()
...
app['web_sockets'] = Sockets(app)
```
### RPC protocol
The RPC protocol has the following structure for incoming messages
```
{
"id": "abc",
"method": "rpc_method_name":
"payload": {
...
}
}
```
The ``id`` is used by clients to link the request with the corresponding response.
The response for an RPC call is eitrher a success
```
{
"id": "abc",
"method": "rpc_method_name":
"result": {
...
}
}
```
or error
```
{
"id": "abc",
"method": "rpc_method_name":
"error": {
...
}
}
```
### Publish/Subscribe
To subscribe to messages, one need to use the ``Subscribe`` mixin with the subscribe RPC handler.
Messages take the form:
```
{
"channel": "channel_name",
"event": "event_name":
"data": {
...
}
}
```
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Utilities
Requires-Python: >=3.6.0
Description-Content-Type: text/markdown
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
aio-openapi-1.2.0.tar.gz
(48.0 kB
view details)
Built Distribution
File details
Details for the file aio-openapi-1.2.0.tar.gz
.
File metadata
- Download URL: aio-openapi-1.2.0.tar.gz
- Upload date:
- Size: 48.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66f4eba50fd039e7221aa5b9814ac2be27d3a2993eabed74fb297c342efac56b |
|
MD5 | 05879caf86a9cd069a0cf07c2a2a3e94 |
|
BLAKE2b-256 | bb6d20c07fdac306a9a7a3d7bd5fe194d92153b1c270b6873a4cb9fc0e750f18 |
File details
Details for the file aio_openapi-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: aio_openapi-1.2.0-py3-none-any.whl
- Upload date:
- Size: 44.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a67c73f9448286a408982abbb68646f7ad1325b8f63ceeeeee8da3e950f108c |
|
MD5 | 34670fbec64425ed741dd7be8a5c84d3 |
|
BLAKE2b-256 | 5087ac650e5e5c48336a8d30bfb22dd7e680bb1017e55c905d8e8485894c14ae |