Generator of python HTTP-clients from OpenApi specification.
Project description
Generator of python HTTP-clients from OpenApi specification based on httpx and pydantic.
Features
- Discriminator
- Metrics
- Logs
- Sync/async clients
Examples
Installation
pip install pythogen
Usage
Generate ordinary clients
- Asynchronous client
pythogen path/to/input/openapi.yaml path/to/output/client.py
- Asynchronous client with integration for metrics
pythogen path/to/input/openapi.yaml path/to/output/client.py --metrics
- Synchronous client
pythogen path/to/input/openapi.yaml path/to/output/client.py --sync
- Synchronous client with integration for metrics
pythogen path/to/input/openapi.yaml path/to/output/client.py --sync --metrics
Generate client as python-package
pythogen path/to/input/openapi.yaml path/to/package/output --package-version=0.0.1 --package-authors="Rick, Morty"
--package-version
— required;--package-authors
— optional;path/to/package/output
— path to the directory where package will be saved.
Usage client
from petstore.client_async import Client
from petstore.client_async import Pet
from petstore.client_async import EmptyBody
client = Client(base_url="http://your.base.url")
pets: list[Pet] | EmptyBody = await client.findPetsByStatus(status="available")
Development
- Activate environment
rm -rf .venv || true python3 -m venv .venv source .venv/bin/activate make requirements
- Make changes
- Execute
make clients-for-tests && make test-clients
- Execute
make clients-for-examples
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.1.16.tar.gz
(19.9 kB
view hashes)
Built Distribution
pythogen-0.1.16-py3-none-any.whl
(27.6 kB
view hashes)
Close
Hashes for pythogen-0.1.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca4af1bd13a45c09acfc065405fb82340589bdcec08002873a7cece0b28524c9 |
|
MD5 | 4dfbc265c9cab44b5e8dce02737cd2c7 |
|
BLAKE2b-256 | 90e7f5833918a2cc1b5d13c5d6175ba263c11915e4e90513b331a522ad108165 |