Lightweight Python OpenAPI 3.x client generator and runtime. Zero Java, zero npm.
Project description
openapi-py-fetch
Lightweight Python OpenAPI 3.x → Python httpx client generator and runtime. Zero Java, zero npm — just Python 3.11+ and your OpenAPI spec.
A fast, single-package alternative to the 200MB+ Java openapi-generator-cli.
Generates typed Python API classes backed by a shared httpx runtime.
Features
- OpenAPI 2.0 & 3.x — handles Swagger and OpenAPI specs
- Shared runtime —
ApiClient,Configuration, and exceptions are a pip-installable library, not duplicated per project - Thin generated output — only API classes are generated; they
import from openapi_py_fetch - No runtime duplication — unlike template-copy generators, the transport layer is maintained in one place
- Drop-in compatible — generated
openapi_clientpackage structure matches openapi-generator output
Installation
pip install openapi-py-fetch
Usage
As a CLI
# Generate client from local spec
openapi-py-fetch openapi.json ./generated_openapi
# Generate from URL
openapi-py-fetch https://petstore.swagger.io/v2/swagger.json ./generated_openapi
# Generate only specific tags
openapi-py-fetch openapi.json ./generated_openapi --tags pet,store
# Dry run — validate and preview without writing files
openapi-py-fetch openapi.json --dry-run
# Check version
openapi-py-fetch --version
As a library (runtime)
from openapi_py_fetch import ApiClient, Configuration, ApiException
config = Configuration(
host="https://petstore.swagger.io/v2",
api_key={"api_key": "special-key"},
)
client = ApiClient(configuration=config)
As a library (generator)
from openapi_py_fetch.generator import generate_client_package
from pathlib import Path
import json
with open("openapi.json") as f:
spec = json.load(f)
generate_client_package(spec, Path("generated_openapi"))
Generated Output Structure
generated_openapi/
├── pyproject.toml # depends on openapi-py-fetch
└── openapi_client/
├── __init__.py # re-exports runtime + API classes
├── api/
│ ├── __init__.py
│ ├── pet_api.py # thin typed wrapper
│ ├── store_api.py
│ └── user_api.py
└── models/
└── __init__.py # stub (schemas are inline)
Comparison with openapi-ts-fetch
| openapi-py-fetch | openapi-ts-fetch | |
|---|---|---|
| Language | Python 3.11+ | TypeScript |
| HTTP transport | httpx | fetch |
| Runtime | Shared pip package | Copied template file |
| Generated output | Python classes | TypeScript classes |
| Models | Inline (dict) | Full interfaces + JSON converters |
License
MIT — Max Health Inc.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openapi_py_fetch-0.2.0.tar.gz.
File metadata
- Download URL: openapi_py_fetch-0.2.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e30ddfef87374141a1b05b9b8a9c8852c12db878cfe910cb5606308173af3a5a
|
|
| MD5 |
46eb7870293737ed62709f3cf302697f
|
|
| BLAKE2b-256 |
21745ade879cbd8b11f5d4ccf1f8008e499dbfb2a2f2a56bf4d1066c0eaa7a5d
|
Provenance
The following attestation bundles were made for openapi_py_fetch-0.2.0.tar.gz:
Publisher:
publish.yml on Max-Health-Inc/openapi-py-fetch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_py_fetch-0.2.0.tar.gz -
Subject digest:
e30ddfef87374141a1b05b9b8a9c8852c12db878cfe910cb5606308173af3a5a - Sigstore transparency entry: 1355519608
- Sigstore integration time:
-
Permalink:
Max-Health-Inc/openapi-py-fetch@8349ccc60ad2b1ba972b04e58ab01b1d21d13fec -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Max-Health-Inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8349ccc60ad2b1ba972b04e58ab01b1d21d13fec -
Trigger Event:
release
-
Statement type:
File details
Details for the file openapi_py_fetch-0.2.0-py3-none-any.whl.
File metadata
- Download URL: openapi_py_fetch-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da9e40e41eb3b11ddda0e70e0dd5b4b766adf62b24592935fc2ed0eb82de1938
|
|
| MD5 |
4f39bcab949e51a783ccd59a244f221d
|
|
| BLAKE2b-256 |
a05bc7989e21d6cdee9a5240ac808b3bb50c3ec2de4c0589a505bf3e2233d44e
|
Provenance
The following attestation bundles were made for openapi_py_fetch-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Max-Health-Inc/openapi-py-fetch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_py_fetch-0.2.0-py3-none-any.whl -
Subject digest:
da9e40e41eb3b11ddda0e70e0dd5b4b766adf62b24592935fc2ed0eb82de1938 - Sigstore transparency entry: 1355519613
- Sigstore integration time:
-
Permalink:
Max-Health-Inc/openapi-py-fetch@8349ccc60ad2b1ba972b04e58ab01b1d21d13fec -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Max-Health-Inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8349ccc60ad2b1ba972b04e58ab01b1d21d13fec -
Trigger Event:
release
-
Statement type: