$ show openapi-ts/openapi-typescript
openapi-typescript is a monorepo of developer tools for consuming OpenAPI 3.x schemas in TypeScript. It provides a CLI and Node.js API to convert any valid OpenAPI specification (3.0/3.1) into TypeScript type definitions (interfaces, unions, enums) with zero runtime overhead. The generated types are used by companion packages: openapi-fetch, a tiny (~6 kB) type-safe fetch client with full parameter serialization, middleware pipeline, and custom serializer support; and openapi-react-query, a ~1 kB wrapper around @tanstack/react-query that provides typed hooks (useQuery, useMutation, useInfiniteQuery, useSuspenseQuery) with automatic query key inference. The monorepo also includes openapi-typescript-helpers, a shared package of utility types (Readable, Writable, FilterKeys, etc.) consumed by the other packages. The architecture is a pnpm workspace with Turborepo orchestration, Biome for linting/formatting, unbuild for package building, and Changesets for versioning. The core code generator (packages/openapi-typescript) uses the TypeScript Compiler API to build AST nodes directly, supporting an extensive set of options (enums, immutable types, path-params-as-types, read/write markers, root types, etc.). The fetch client (packages/openapi-fetch) implements full OpenAPI parameter serialization styles, a middleware system with onRequest/onResponse/onError lifecycle hooks, and a path-based client proxy for ergonomic endpoint access. All packages are thoroughly tested with unit tests, snapshot tests against real-world APIs (GitHub, Stripe, DigitalOcean), and e2e tests using Playwright. The repository includes comprehensive documentation (English, Japanese, Chinese) with a VitePress site, framework examples (Next.js, SvelteKit, Vue 3), and benchmarking against alternatives. The project is actively maintained with a large community (8.4k stars, 287 open issues, 672 forks) and is used in production by companies such as Netlify, Supabase, Google Firebase CLI, and GitHub Octokit.
The LLM identified 3 files worth highlighting for reuse:
The core runtime of openapi-fetch. Provides createClient with full OpenAPI parameter serialization (path, query, header, cookie styles), a middleware pipeline (onRequest, onResponse, onError) with registration-order semantics, custom serializers per instance or per request, and a proxy-based path-based client (wrapAsPathBasedClient). The middleware and serializer functions are self-contained and can be extracted for use in other fetch-based tools or as a standalone typed middleware system.
A collection of helper functions for programmatically building TypeScript AST nodes using the TypeScript Compiler API (ts.factory). Includes tsEnum, tsUnion, tsIntersection, tsLiteral, tsPropertyIndex, addJSDocComment, oapiRef, and astToString. These utilities are self-contained, accept standard TypeScript types, and are used across the entire transform pipeline. They can be extracted for any project that needs to generate TypeScript type declarations programmatically.
Published type utilities for OpenAPI-related TypeScript code. Provides conditional types like Readable<T>, Writable<T>, FilterKeys, HasRequiredKeys, and media-type extraction helpers. These are designed to be imported by both openapi-fetch and openapi-react-query (and any third-party consumer) to handle read/write visibility, success/error response extraction, and type narrowing. The package is minimal and decoupled, making it a reusable pattern for sharing type helpers across packages in a monorepo.