Generator of python HTTP-clients from OpenApi specification based on httpx and pydantic.
Overview
Installation
with pip
with docker
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
or via Dockerdocker 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
Use the generated client. Below is an example of using a client generated for Petstore OpenAPI.
from petstore.client_async import Client
from petstore.client_async import Pet
from petstore.client_async import EmptyBody
from petstore.client_async import FindPetsByStatusQueryParams
pets: list[Pet] | EmptyBody = await client.findPetsByStatus(
query_params=FindPetsByStatusQueryParams(status="available"),
)
Examples
- Sync and async clients for Petstore OpenAPI