# openapi-ts/openapi-typescript architecture

> Architecture diagram of the GitHub repository openapi-ts/openapi-typescript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openapi-ts/openapi-typescript
- Repository: https://github.com/openapi-ts/openapi-typescript

## Overview

#### Purpose and topology
This pnpm/Turbo monorepo provides TypeScript tooling around OpenAPI schemas: a schema-to-TypeScript generator plus typed HTTP-client integrations. Primary published packages are `openapi-typescript`, `openapi-fetch`, `openapi-react-query`, and type helpers. Root workspace/build coordination is in `package.json`, `pnpm-workspace.yaml`, and `turbo.json`.

#### Generator: OpenAPI schema → TypeScript declarations
`openapi-typescript` is the central compile-time pipeline. Its programmatic API starts at `packages/openapi-typescript/src/index.ts`; its Node CLI entry point is `packages/openapi-typescript/bin/cli.js`. It accepts static OpenAPI documents, resolves/processes them, then emits TypeScript declarations. The package’s broad DigitalOcean, GitHub, and Stripe schemas are generation fixtures/examples rather than runtime application data.

#### Transformation layer
The generator decomposes OpenAPI conversion by specification object type. `packages/openapi-typescript/src/transform/index.ts` coordinates transforms; `packages/openapi-typescript/src/transform/schema-object.ts` maps JSON Schema/OpenAPI schemas into TS AST/types; `packages/openapi-typescript/src/transform/paths-object.ts` and `packages/openapi-typescript/src/transform/operation-object.ts` produce typed path/operation structures. This is the main semantic boundary: arbitrary OpenAPI input becomes generated static TypeScript surface area.

#### Type emission and schema processing boundary
Shared generator contracts and output mechanics live in `packages/openapi-typescript/src/types.ts`, `packages/openapi-typescript/src/lib/ts.ts`, and `packages/openapi-typescript/src/lib/redoc.ts`. The presence of Redocly-oriented fixtures/configuration indicates schema loading, bundling, linting, or reference handling is delegated through that ecosystem rather than implemented wholly as local transforms. The generator runs in Node.js and produces files consumed by downstream TypeScript builds.

#### Typed fetch runtime
`openapi-fetch` is the runtime counterpart for generated schema types. `packages/openapi-fetch/src/index.js` implements the client runtime, while `packages/openapi-fetch/src/index.d.ts` defines its typed API. Consumer control flow is: generated OpenAPI types parameterize a client → typed path/method invocation builds an HTTP request → Fetch-compatible transport executes it → response is exposed with schema-derived success/error typing. Middleware, parameter encoding, request construction, and response parsing are architecturally central runtime concerns, evidenced by `packages/openapi-fetch/test/common` and `packages/openapi-fetch/test/middleware`.

#### React Query integration and helper layer
`openapi-react-query` adapts typed OpenAPI fetch clients into TanStack React Query-oriented query, infinite-query, mutation, and suspense-query APIs; its public surface is concentrated in `packages/openapi-react-query/src/index.ts`. `packages/openapi-typescript-helpers/src/index.ts` provides reusable type-level utilities for generated/consuming code. These packages are integration layers: they should depend on stable generated types and client interfaces, not on generator internals.

#### Documentation, examples, and delivery infrastructure
The documentation site is a VitePress project rooted at `docs/.vitepress/config.ts`, with package usage guides under `docs/openapi-fetch` and `docs/openapi-react-query`. Framework examples demonstrate client consumption in Next.js, SvelteKit, and Vue under `packages/openapi-fetch/examples`. CI/release automation is GitHub Actions-based (`.github/workflows/ci.yml`, `.github/workflows/release.yml`); Changesets (`.changeset/config.json`) govern package versioning. External hosted services explicitly used for docs are Cloudflare Pages and Algolia search.

Main entry points: [`packages/openapi-fetch/src/index.js`](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-fetch/src/index.js) (openapi-fetch), [`package.json`](https://github.com/openapi-ts/openapi-typescript/blob/main/package.json) (pnpm / Turbo workspace), [`packages/openapi-react-query/src/index.ts`](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-react-query/src/index.ts) (openapi-react-query), [`packages/openapi-typescript/src/transform/index.ts`](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/transform/index.ts) (Transform coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace &amp; delivery"]
  node_monorepo["pnpm / Turbo workspace<br/>build coordination<br/>[package.json]"]
  node_ci["CI workflow<br/>GitHub Actions<br/>[ci.yml]"]
  node_release["Release workflow<br/>GitHub Actions<br/>[release.yml]"]
  node_changesets["Changesets<br/>versioning<br/>[config.json]"]
end

subgraph group_generator["Schema generator"]
  node_generator_api["Generator API<br/>TypeScript API<br/>[index.ts]"]
  node_generator_cli["Generator CLI<br/>Node CLI<br/>[cli.js]"]
  node_schema_processing["Schema processing<br/>Redocly boundary<br/>[redoc.ts]"]
  node_transform_coordinator["Transform coordinator<br/>OpenAPI transforms<br/>[index.ts]"]
  node_schema_transform["Schema transform<br/>JSON Schema → TS<br/>[schema-object.ts]"]
  node_path_operations["Path &amp; operation transforms<br/>OpenAPI → TS<br/>[paths-object.ts]"]
  node_ts_emitter["Type declaration emitter<br/>TS output<br/>[ts.ts]"]
  node_generated_types["Generated OpenAPI types<br/>TypeScript declarations"]
end

subgraph group_runtime["Typed client integrations"]
  node_fetch_client["openapi-fetch<br/>typed fetch runtime<br/>[index.js]"]
  node_fetch_types["Fetch client types<br/>TypeScript declarations<br/>[index.d.ts]"]
  node_fetch_transport{{"Fetch-compatible transport<br/>HTTP transport"}}
  node_react_query["openapi-react-query<br/>TanStack Query adapter<br/>[index.ts]"]
  node_type_helpers["Type helpers<br/>type-level utilities<br/>[index.ts]"]
end

subgraph group_docs["Docs &amp; examples"]
  node_docs_site["VitePress docs<br/>documentation site<br/>[config.ts]"]
  node_framework_examples["Framework examples<br/>consumer examples"]
  node_hosted_docs{{"Cloudflare Pages &amp; Algolia<br/>hosted docs services"}}
end

node_monorepo -->|"builds"| node_generator_api
node_monorepo -->|"builds"| node_fetch_client
node_monorepo -->|"builds"| node_react_query
node_ci -->|"validates"| node_monorepo
node_release -->|"uses"| node_changesets
node_release -->|"publishes packages"| node_monorepo
node_generator_cli -->|"invokes"| node_generator_api
node_generator_api -->|"processes input"| node_schema_processing
node_schema_processing -->|"resolved OpenAPI"| node_transform_coordinator
node_transform_coordinator -->|"transforms schemas"| node_schema_transform
node_transform_coordinator -->|"transforms paths"| node_path_operations
node_schema_transform -->|"TS AST/types"| node_ts_emitter
node_path_operations -->|"operations"| node_ts_emitter
node_ts_emitter -->|"emits"| node_generated_types
node_generated_types -->|"parameterizes client"| node_fetch_types
node_fetch_types -->|"types runtime API"| node_fetch_client
node_fetch_client -->|"executes requests"| node_fetch_transport
node_fetch_client -->|"client interface"| node_react_query
node_generated_types -->|"schema typing"| node_react_query
node_type_helpers -.->|"supports consumers"| node_generated_types
node_fetch_client -.->|"demonstrated by"| node_framework_examples
node_fetch_client -.->|"documented in"| node_docs_site
node_react_query -.->|"documented in"| node_docs_site
node_docs_site -->|"deployed and searched"| node_hosted_docs

click node_monorepo "https://github.com/openapi-ts/openapi-typescript/blob/main/package.json"
click node_ci "https://github.com/openapi-ts/openapi-typescript/blob/main/.github/workflows/ci.yml"
click node_release "https://github.com/openapi-ts/openapi-typescript/blob/main/.github/workflows/release.yml"
click node_changesets "https://github.com/openapi-ts/openapi-typescript/blob/main/.changeset/config.json"
click node_generator_api "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/index.ts"
click node_generator_cli "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/bin/cli.js"
click node_schema_processing "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/lib/redoc.ts"
click node_transform_coordinator "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/transform/index.ts"
click node_schema_transform "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/transform/schema-object.ts"
click node_path_operations "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/transform/paths-object.ts"
click node_ts_emitter "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/lib/ts.ts"
click node_fetch_client "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-fetch/src/index.js"
click node_fetch_types "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-fetch/src/index.d.ts"
click node_react_query "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-react-query/src/index.ts"
click node_type_helpers "https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript-helpers/src/index.ts"
click node_docs_site "https://github.com/openapi-ts/openapi-typescript/blob/main/docs/.vitepress/config.ts"
click node_framework_examples "https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-fetch/examples"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_monorepo,node_ci,node_release,node_changesets toneBlue
class node_generator_api,node_generator_cli,node_schema_processing,node_transform_coordinator,node_schema_transform,node_path_operations,node_ts_emitter,node_generated_types toneAmber
class node_fetch_client,node_fetch_types,node_fetch_transport,node_react_query,node_type_helpers toneMint
class node_docs_site,node_framework_examples,node_hosted_docs toneRose
```

## Components

### Workspace & delivery

- [pnpm / Turbo workspace](https://github.com/openapi-ts/openapi-typescript/blob/main/package.json): build coordination · Coordinates package builds and publishing. · `package.json`
- [CI workflow](https://github.com/openapi-ts/openapi-typescript/blob/main/.github/workflows/ci.yml): GitHub Actions · `.github/workflows/ci.yml`
- [Release workflow](https://github.com/openapi-ts/openapi-typescript/blob/main/.github/workflows/release.yml): GitHub Actions · `.github/workflows/release.yml`
- [Changesets](https://github.com/openapi-ts/openapi-typescript/blob/main/.changeset/config.json): versioning · `.changeset/config.json`

### Schema generator

- [Generator API](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/index.ts): TypeScript API · `packages/openapi-typescript/src/index.ts`
- [Generator CLI](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/bin/cli.js): Node CLI · `packages/openapi-typescript/bin/cli.js`
- [Schema processing](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/lib/redoc.ts): Redocly boundary · Loads, bundles, lints, and resolves OpenAPI documents. · `packages/openapi-typescript/src/lib/redoc.ts`
- [Transform coordinator](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/transform/index.ts): OpenAPI transforms · `packages/openapi-typescript/src/transform/index.ts`
- [Schema transform](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/transform/schema-object.ts): JSON Schema → TS · `packages/openapi-typescript/src/transform/schema-object.ts`
- [Path & operation transforms](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/transform/paths-object.ts): OpenAPI → TS · `packages/openapi-typescript/src/transform/paths-object.ts`
- [Type declaration emitter](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/lib/ts.ts): TS output · Emits generated declaration surface using shared contracts. · `packages/openapi-typescript/src/lib/ts.ts`
- **Generated OpenAPI types**: TypeScript declarations

### Typed client integrations

- [openapi-fetch](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-fetch/src/index.js): typed fetch runtime · Builds requests, runs middleware, and parses typed responses. · `packages/openapi-fetch/src/index.js`
- [Fetch client types](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-fetch/src/index.d.ts): TypeScript declarations · `packages/openapi-fetch/src/index.d.ts`
- **Fetch-compatible transport**: HTTP transport
- [openapi-react-query](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-react-query/src/index.ts): TanStack Query adapter · Exposes typed query, infinite-query, mutation, and suspense APIs. · `packages/openapi-react-query/src/index.ts`
- [Type helpers](https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript-helpers/src/index.ts): type-level utilities · `packages/openapi-typescript-helpers/src/index.ts`

### Docs & examples

- [VitePress docs](https://github.com/openapi-ts/openapi-typescript/blob/main/docs/.vitepress/config.ts): documentation site · `docs/.vitepress/config.ts`
- [Framework examples](https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-fetch/examples): consumer examples · Next.js, SvelteKit, and Vue client-consumption examples. · `packages/openapi-fetch/examples`
- **Cloudflare Pages & Algolia**: hosted docs services

## Connections

- pnpm / Turbo workspace → Generator API: builds
- pnpm / Turbo workspace → openapi-fetch: builds
- pnpm / Turbo workspace → openapi-react-query: builds
- CI workflow → pnpm / Turbo workspace: validates
- Release workflow → Changesets: uses
- Release workflow → pnpm / Turbo workspace: publishes packages
- Generator CLI → Generator API: invokes
- Generator API → Schema processing: processes input
- Schema processing → Transform coordinator: resolved OpenAPI
- Transform coordinator → Schema transform: transforms schemas
- Transform coordinator → Path & operation transforms: transforms paths
- Schema transform → Type declaration emitter: TS AST/types
- Path & operation transforms → Type declaration emitter: operations
- Type declaration emitter → Generated OpenAPI types: emits
- Generated OpenAPI types → Fetch client types: parameterizes client
- Fetch client types → openapi-fetch: types runtime API
- openapi-fetch → Fetch-compatible transport: executes requests
- openapi-fetch → openapi-react-query: client interface
- Generated OpenAPI types → openapi-react-query: schema typing
- Type helpers → Generated OpenAPI types: supports consumers
- openapi-fetch → Framework examples: demonstrated by
- openapi-fetch → VitePress docs: documented in
- openapi-react-query → VitePress docs: documented in
- VitePress docs → Cloudflare Pages & Algolia: deployed and searched
