OpenAPI Client for Python
A Python implementation inspired by openapi-client-axios that provides a dynamic client for OpenAPI specifications. This implementation uses httpx for HTTP requests and Python's metaprogramming capabilities to dynamically generate a client.
Installation
pip install -e .
Usage
from openapiclient import OpenAPIClient
import asyncio
async def main():
# Initialize the client with the OpenAPI definition
api = OpenAPIClient(definition="https://petstore3.swagger.io/api/v3/openapi.json")
try:
# Initialize and get the dynamic client
client = await api.init()
# Call an operation using the generated method
response = await client.getPetById(petId=1)
# Print the response
print(f"Status code: {response['status']}")
print(f"Pet data: {response['data']}")
finally:
# Close the HTTP session
await api.close()
if __name__ == "__main__":
asyncio.run(main())
Features
- Dynamic client generation using Python metaprogramming
- Supports OpenAPI 3.0 and 3.1
- Supports JSON and YAML specification formats
- Supports specification loading from URL, file, or dictionary
- Asynchronous API using httpx
- Response format similar to axios (data, status, headers, config)
Author
lloydzhou (2025-02-27)
Metadata
Release files for httpx-openapi-gen 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| httpx_openapi_gen-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for httpx_openapi_gen-0.1.0-py3-none-any.whl |
Release files / httpx_openapi_gen-0.1.0-py3-none-any.whl
| Download URL | httpx_openapi_gen-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b60ca232fc7295b45c53ec6c485cc417ef5b9fda8939c7616643cb42ffa4ea67
|
|
BLAKE2b-256 checksum How to use checksums |
5882c3db2d3ff72619c788ad5f84b7eb0456b82e7ce8a7d9b37cd72854da8176
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.2
|
Security for httpx-openapi-gen 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.