Convience functionality to create python modules from zserio services at warp speed.
Project description
Zswag
Convience functionality to create python modules from zserio services at warp speed. Translate/verify Zserio services to/with OpenAPI/Swagger and serve them in Flask/Connexion WSGI apps.
Installation
Clone this repository, and run
pip3 install -e .
Creating a Swagger service from zserio
ZserioSwaggerApp
gives you the power to marry a user-written app controller
with a zserio-generated app server class (argument parser/response serialiser)
and a fitting Swagger OpenAPI spec.
Example
import zswag
import zserio
import my.app.controller
zserio.require("myapp/service.zs")
from myapp.service import Service
# The OpenApi argument `yaml_path=...` is optional
app = zswag.ZserioSwaggerApp(my.app.controller, Service)
Here, the API endpoints are routed to my/app/controller.py
,
which might look as follows:
# Written by you
def myApi(request):
return "response"
# Injected by ZserioSwaggerApp
# _service = Service()
# _service.myApi = lambda request: _service._myApiMethod(request)
# _service._myApiImpl = my.app.controller.myApi
FYI
The OpenAPI spec is auto-generated if you do not specify an existing file. If you specify an empty YAML path, the yaml file is placed next to the zserio python-service source-file.
If you have installed pip install connexion[swagger-ui]
, you can view
API docs of your service under [/prefix]/ui
.
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 zswag-0.2.0.tar.gz
.
File metadata
- Download URL: zswag-0.2.0.tar.gz
- Upload date:
- Size: 4.7 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.45.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1db94b908aed1bc0903502c2ea313b7eb87d5cebd4776822d0b168c379755c39 |
|
MD5 | 7215e5c3a4559c37504c5d1aaa776252 |
|
BLAKE2b-256 | 56f10e7ccf85d489e1a270d57f564edf37c96b3d7d2050686f8041218393e93a |
Provenance
File details
Details for the file zswag-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: zswag-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.1 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.45.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7587dc55d82d067db0efc672e1d549b41c26fb899ab00058224825a43b9df078 |
|
MD5 | 6d999029f13bce4c3d2ba7946c8c5ba6 |
|
BLAKE2b-256 | df1a0cd57eb49d0e0e48c9705157e2e40ff210f5e346d6698475c38a75b5ed31 |