Skip to main content

openapi-ts-fetch

PyPI CI License: MIT Python 3.10+

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
  • Remote & local specs — load from URLs or local JSON/YAML files
  • 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
  • Dry-run mode — validate spec and preview what would be generated
  • No runtime dependencies — pure Python stdlib, TypeScript output uses only fetch
  • Drop-in compatible — output matches the openapi-generator TypeScript-fetch structure

Installation

pip install openapi-ts-fetch

# Or with uv
uv tool install openapi-ts-fetch

Usage

# Generate full client from local spec
openapi-ts-fetch openapi.json ./src/api-client

# Generate from a remote URL
openapi-ts-fetch https://petstore3.swagger.io/api/v3/openapi.json ./src/api-client

# Generate only specific API tags (and their referenced models)
openapi-ts-fetch openapi.json ./src/api-client --tags users,orders

# Override BASE_PATH in generated runtime.ts
openapi-ts-fetch openapi.json ./src/api-client --base-path /api/v1

# Validate spec without generating (dry-run)
openapi-ts-fetch openapi.json ./src/api-client --dry-run

# Check version
openapi-ts-fetch --version

From Python

from openapi_ts_fetch import generate

model_files, api_files = generate("openapi.json", "./src/api-client", tag_filter={"shl"})

The package also exposes the pieces the generator is built from: SchemaRegistry (inline-schema extraction and dedup), gen_model and gen_api (the two emitters), and the naming helpers pascal, camel and operation_id.

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'
openapi-ts-fetch 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

  1. title field — uses the schema's title if present (frameworks like Elysia/TypeBox set these automatically)
  2. Content-hash dedup — identical schemas with the same title share a single model
  3. Nested objects — ParentName + PropertyName (PascalCase)
  4. Array items — ParentName + PropertyName + "Inner"
  5. Fallback — OperationId + StatusCode + "Response" / "Request"

License

MIT — Max Health Inc.

Metadata

Release files for openapi-ts-fetch 0.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 openapi-ts-fetch 0.3.1
File Size Uploaded Provenance Actions
openapi_ts_fetch-0.3.1.tar.gz 28.0 kB With provenance Details for openapi_ts_fetch-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openapi-ts-fetch 0.3.1
File Interpreter ABI Platform Actions
openapi_ts_fetch-0.3.1-py3-none-any.whl Python 3 none any Details for openapi_ts_fetch-0.3.1-py3-none-any.whl

Total release size: 52.0 kB

Release files / openapi_ts_fetch-0.3.1.tar.gz

Download URL openapi_ts_fetch-0.3.1.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b5d7e71b4eaf8cf6eddea6eab4d1dbd8d76225cd53dd613cb45f57d1f0cf0b88
BLAKE2b-256 checksum
How to use checksums
b4e8c525296f389a477ad896850fcbbc508bd1907a41e35f6afd12a3d39aeffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / openapi_ts_fetch-0.3.1-py3-none-any.whl

Download URL openapi_ts_fetch-0.3.1-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2082b1ec754101aea12060c39b4175e9dff8b0f43e6a2ec824f3c9f6ed2f061
BLAKE2b-256 checksum
How to use checksums
c27929a4644c3056490d31ef7beea22b70d2bdf2e51f10d4741fd5fe49390510
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for openapi-ts-fetch 0.3.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for openapi_ts_fetch-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

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.

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