Generator of python HTTP-clients from OpenApi specification.
Project description
Generator of python HTTP-clients from OpenApi specification based on httpx and pydantic
Documentation: https://artsmolin.github.io/pythogen
Source Code: https://github.com/artsmolin/pythogen
Examples: sync and async clients for Petstore OpenAPI
Installation
You can install the library
pip install pythogen
or use Docker
docker pull artsmolin/pythogen
Generation
path/to/input
— path to the directory with openapi.yaml;path/to/output
— the path to the directory where the generated client will be saved;
Generate a client using the installed library
pythogen path/to/input/openapi.yaml path/to/output/client.py
or via Docker
docker run \
-v ./path/to/input:/opt/path/to/input \
-v ./path/to/output:/opt/path/to/output \
artsmolin/pythogen \
path/to/input/openapi.yaml \
path/to/output/client.py
Usage
from petstore.client_async import Client
from petstore.client_async import Pet
from petstore.client_async import EmptyBody
from petstore.client_async import FindPetsByStatusQueryParams
client = Client(base_url="http://your.base.url")
pets: list[Pet] | EmptyBody = await client.findPetsByStatus(
query_params=FindPetsByStatusQueryParams(status="available"),
)
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
pythogen-0.2.39.tar.gz
(22.4 kB
view hashes)
Built Distribution
pythogen-0.2.39-py3-none-any.whl
(30.9 kB
view hashes)
Close
Hashes for pythogen-0.2.39-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22936d9d51f29430444e8c40157b4b4f8d21ed565e22dd64baf72a014232e5ba |
|
MD5 | 0bf1bd70ec9e6336d17061ee5a388bff |
|
BLAKE2b-256 | 3583b577770fc8541b66a3544e2c3570220b4b0466360ae0ea5dba72ff82cf8c |