Skip to main content

python-client-generator

Python package to generate an httpx- and pydantic-based async (or sync) client off an OpenAPI spec >= 3.0 (partial specification support).

flowchart LR
    generator["python-client-generator"]
    app["REST API App"]
    package["App HTTP client"]

    app -- "OpenAPI JSON" --> generator
    generator -- "Generates" --> package

:warning: Currently does not support OpenAPI 2.x (PRs for < 3.0 support are welcome).

:exclamation: Only partial OpenAPI specification support, if you encounter unsupported spec. please feel free to contribute to the project.

Using the generator

Install the package (see on PyPi):

pip install python-client-generator

Run:

python -m python_client_generator --open-api openapi.json --package-name foo_bar --project-name foo-bar --outdir clients

This will produce a Python package with the following structure:

clients
├── foo_bar
│   ├── __init__.py
│   ├── apis.py
│   ├── base_client.py
│   └── models.py
└── pyproject.toml

Using PATCH functions from the generator

When calling one of the generated update functions that uses an HTTP PATCH method, you'll probably want to pass the additional argument body_serializer_args={"exclude_unset": True}. This will ensure that only the fields that are set in the update object are sent to the API. Example:

await api_client.update_contact_v1_contacts__contact_id__patch(
    body=patch_body,
    contact_id=contact.id,
    tenant=tenant,
    body_serializer_args={"exclude_unset": True}
)

Contributing

Please refer to CONTRIBUTING.md.

Metadata

Release files for python-client-generator 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-client-generator 1.3.1
File Size Uploaded
python_client_generator-1.3.1.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-client-generator 1.3.1
File Interpreter ABI Platform
python_client_generator-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.9 kB

Release files / python_client_generator-1.3.1.tar.gz

Download URL python_client_generator-1.3.1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ba7f28b37a0fffab8f58f87e9f0b67cb82c281cbd17ecd2038071548b7fed595
BLAKE2b-256 checksum
How to use checksums
0280f66559cc1d2bb8a8554cb32133e2c1abc95a82137e21ece7a6dbf1c50b75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.8.18 Linux/6.11.0-1015-azure

Release files / python_client_generator-1.3.1-py3-none-any.whl

Download URL python_client_generator-1.3.1-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
451e2430344adebf6ead8fef3447e4893ab9468541470c794ea72965de348870
BLAKE2b-256 checksum
How to use checksums
cd0058e130693b7c32dd3fc5558c6058073aca892c772367802d1bb4896e64be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.8.18 Linux/6.11.0-1015-azure

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page