Lightweight Python OpenAPI 3.x → TypeScript fetch client generator. Zero Java, zero npm.
Project description
openapi-ts-fetch
Lightweight Python OpenAPI 3.x → TypeScript fetch client generator. Zero Java, zero npm — just Python 3.10+ and your OpenAPI spec.
A fast, single-file alternative to the 200MB+ Java openapi-generator-cli. Generates fully typed TypeScript fetch clients with the same output structure.
Features
- OpenAPI 3.0.3 & 3.1.x — handles both spec versions natively
- Schema deduplication — identical schemas share a single model via content-hash
- Nested extraction — inline object properties and array items become named models
- Tag filtering — generate only the APIs you need with
--tags - No runtime dependencies — pure Python stdlib, TypeScript output uses only
fetch - Drop-in compatible — output matches the
openapi-generatorTypeScript-fetch structure
Installation
# Option 1: pip install (coming soon)
pip install openapi-ts-fetch
# Option 2: just copy the two files
curl -O https://raw.githubusercontent.com/Max-Health-Inc/openapi-ts-fetch/main/generate.py
curl -O https://raw.githubusercontent.com/Max-Health-Inc/openapi-ts-fetch/main/runtime-template.ts
Usage
# Generate full client
python generate.py openapi.json ./src/api-client
# Generate only specific API tags (and their referenced models)
python generate.py openapi.json ./src/api-client --tags users,orders
# From pip install
openapi-ts-fetch openapi.json ./src/api-client --tags users
Output Structure
src/api-client/
├── runtime.ts # Configuration, BaseAPI, middleware, fetch helpers
├── index.ts # Barrel exports
├── apis/
│ ├── index.ts
│ ├── UsersApi.ts # One class per OpenAPI tag
│ └── OrdersApi.ts
└── models/
├── index.ts
├── User.ts # Interface + FromJSON/ToJSON
└── CreateUserRequest.ts
Using the Generated Client
import { Configuration, UsersApi } from './api-client'
const config = new Configuration({
basePath: 'https://api.example.com',
accessToken: async () => getMyToken(),
})
const users = new UsersApi(config)
// Fully typed request and response
const user = await users.getUser({ id: '123' })
console.log(user.name)
Tag Filtering
When you only need a subset of your API in a particular app, use --tags to generate a lean client:
# Full API has 26 tags and 220 models, but your app only uses 'shl'
python generate.py openapi.json ./src/api-client --tags shl
# Output: 1 API class, 3 models (only transitively referenced ones)
This is especially useful in monorepos where different apps consume different parts of the same backend API.
Comparison
| openapi-ts-fetch | openapi-generator-cli | |
|---|---|---|
| Runtime | Python 3.10+ (~1000 LOC) | Java 11+ (~200MB JAR) |
| Install | pip install or copy 2 files |
Docker / Java / npm wrapper |
| Speed | ~1s for 200+ models | ~10s+ for same spec |
| Tag filtering | Built-in --tags |
Templates + config |
| Schema dedup | Content-hash based | Limited |
| Output | TypeScript fetch | TypeScript fetch (+ 40 others) |
Schema Naming Strategy
titlefield — uses the schema'stitleif present (frameworks like Elysia/TypeBox set these automatically)- Content-hash dedup — identical schemas with the same title share a single model
- Nested objects —
ParentName+PropertyName(PascalCase) - Array items —
ParentName+PropertyName+"Inner" - Fallback —
OperationId+StatusCode+"Response"/"Request"
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_ts_fetch-0.1.0.tar.gz.
File metadata
- Download URL: openapi_ts_fetch-0.1.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60760399cd15f7c0bfc11e6288974519793bb545d4a325ff9b7d54a9783c9d76
|
|
| MD5 |
ee460975f31c5a4db0bdbe9578ef9f1b
|
|
| BLAKE2b-256 |
9d7f03a41e98dff55d206a98b938db71f010a0be9a77f8249aaecc706f22599b
|
Provenance
The following attestation bundles were made for openapi_ts_fetch-0.1.0.tar.gz:
Publisher:
publish.yml on Max-Health-Inc/openapi-ts-fetch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_ts_fetch-0.1.0.tar.gz -
Subject digest:
60760399cd15f7c0bfc11e6288974519793bb545d4a325ff9b7d54a9783c9d76 - Sigstore transparency entry: 1340474297
- Sigstore integration time:
-
Permalink:
Max-Health-Inc/openapi-ts-fetch@a92bf4f447f5a5f3cf49d56bce7e94309937dfeb -
Branch / Tag:
refs/tags/v0.1.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@a92bf4f447f5a5f3cf49d56bce7e94309937dfeb -
Trigger Event:
release
-
Statement type:
File details
Details for the file openapi_ts_fetch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openapi_ts_fetch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.8 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 |
1850c304eea093231603806eb27900a2e3973f85087783e63234f1fd6711f1c7
|
|
| MD5 |
77670eaba5cf388cad16cf6e7082efc3
|
|
| BLAKE2b-256 |
13c03c4d3734ee07891bb0e8e92cb161f9a7f4731a339a0bd261bd91a2c5557e
|
Provenance
The following attestation bundles were made for openapi_ts_fetch-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Max-Health-Inc/openapi-ts-fetch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_ts_fetch-0.1.0-py3-none-any.whl -
Subject digest:
1850c304eea093231603806eb27900a2e3973f85087783e63234f1fd6711f1c7 - Sigstore transparency entry: 1340474301
- Sigstore integration time:
-
Permalink:
Max-Health-Inc/openapi-ts-fetch@a92bf4f447f5a5f3cf49d56bce7e94309937dfeb -
Branch / Tag:
refs/tags/v0.1.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@a92bf4f447f5a5f3cf49d56bce7e94309937dfeb -
Trigger Event:
release
-
Statement type: