Registry / http-networking / openapi-python-client

openapi-python-client

JSON →
library0.29.0pypypi✓ verified 23d ago

OpenAPI Python Client Generator is a Python library and CLI tool that generates modern, type-hinted Python clients from OpenAPI specifications. It supports both OpenAPI v2 (Swagger) and v3 specifications, generating Pydantic-based models and httpx-based clients. It's actively maintained with frequent releases, currently at version 0.28.3.

pip install openapi-python-client
INSTALL
IMPORT
SIG · OPENAPI-PYTHON-CLI
O
openapi-python-client
http-networkingpythonv0.29.0
Install
6.9s avg
Import
1225ms
Disk
49MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.28.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.270s · 50.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 6.9s · import 1.180s · 50MB
49MB installed
● package 49MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Project
from openapi_python_client import Project
from openapi_python_client import create_new_client
Config
from openapi_python_client import Config
GeneratorData
from openapi_python_client import GeneratorData

Generates a Python client for the Petstore API from its OpenAPI specification. The primary interaction with openapi-python-client is via its command-line interface. The generated client is then imported and used like a standard Python library.

openapi-python-client generate --url https://petstore.swagger.io/v2/swagger.json --path my-api-client # The above command generates a client in the 'my-api-client' directory. # Example usage of the generated client (assuming 'my-api-client' is in your PYTHONPATH): # import my_api_client.client as my_client # client = my_client.Client(base_url="https://petstore.swagger.io/v2") # # You can now use client.pet, client.store, etc. # response = client.pet.find_pets_by_status(status="available") # if response.status_code == 200: # pets = response.parsed # for pet in pets: # print(pet.name)
openapi-python-client --version
Debug
Known issues
breakingBreaking changes to `create_new_client` arguments and output directory structure.
fix
The `name` argument was renamed to `path` in `create_new_client`. The output directory structure also changed from `{output_path}` to `{output_path}/{project_name}/`. Adjust programmatic calls and expect a new directory layout.
affects: >=0.28.0
breakingCore model classes and methods were renamed or removed.
fix
`BaseModel` was replaced by `PydanticBaseModel` and `TypingBaseModel`. The `from_dict` method was removed from models, and `_get_kwargs` was renamed to `_prepped_request` on `_Endpoint` classes. Update any custom code interacting directly with these internal components.
affects: >=0.27.0
breaking`httpx` and `mypy` became mandatory dependencies/generated code.
fix
Prior to 0.23.0, `httpx` was optional and `mypy` generation could be disabled. Since 0.23.0, `httpx` is a direct dependency and `mypy` type hints are always generated. Ensure your environment allows for these dependencies and integrate mypy checks into your workflow if not already.
affects: >=0.23.0
breakingPydantic V2 support introduced, requiring Pydantic >= 2.0.
fix
Clients generated with `openapi-python-client` versions 0.21.0 and above require Pydantic V2. If you have existing code using Pydantic V1 and wish to regenerate your client, you might need to manage Pydantic versions carefully or update your application to Pydantic V2.
affects: >=0.21.0
gotchaComplex OpenAPI schemas (e.g., `oneOf`, `allOf`, discriminators) can lead to challenging type generation.
fix
While `openapi-python-client` attempts to handle complex types, especially those involving `oneOf`/`anyOf`/`allOf` or discriminator patterns, the resulting Pydantic models can sometimes be difficult to work with or might not perfectly reflect the intended schema logic. Always review the generated client's models and their types, and test thoroughly. Custom templates can be used for advanced control.
affects: all
Upgrade
Version history
0.29.0latest on PyPI · released May 30, 2026
Audit
Dependencies
pydanticrequiredUsed for data models in generated clients. Version 2.x is preferred since 0.21.0.
httpxrequiredUsed as the HTTP client for generated clients. Required since 0.23.0.
Agent activity
22 hits · last 30 days
node
20
Amazon
1
Resources
openapi-python-client — pip install openapi-python-client · libregistry