Command-line tool that generates API client SDKs, server stubs and HTML docs from an OpenAPI/Swagger definition.
openapi-ts/openapi-typescript
Generates TypeScript types from OpenAPI 3 schemas, plus a type-safe fetch client built on those types.
- Stars
- 8,428
- Forks
- 675
- Open issues
- 287
- Last commit
- last month
What is it?
openapi-typescript is a monorepo with two packages for working with OpenAPI schemas in TypeScript. The main package, openapi-typescript, converts a static OpenAPI 3 schema into TypeScript type definitions, so request paths, parameters, and response bodies can be checked at compile time instead of being written by hand.
The second package, openapi-fetch, is a small fetch wrapper that uses those generated types. Requests and responses are typed against the schema, so mismatches between client code and the API definition surface as TypeScript errors.
The project is aimed at frontend and full-stack teams that already maintain an OpenAPI description of their API and want typed client code without writing or maintaining it manually.
Key features
- 01Converts static OpenAPI 3 schemas into TypeScript type definitions.
- 02Provides openapi-fetch, a fetch client typed from the generated schema types.
- 03Catches mismatches between client calls and API definitions at compile time.
- 04Supports OpenAPI 3.1 as indicated by the project's topics.
Use cases
- Generating typed API client models for a frontend app from a backend's OpenAPI file.
- Building a type-safe fetch client for an existing REST API.
- Keeping client types in sync with a changing API schema in CI.
Quick start
- 1
Install openapi-typescript from npm
npm i -D openapi-typescript typescript - 2
Generate types from an OpenAPI schema
npx openapi-typescript https://petstore3.swagger.io/api/v3/openapi.json -o ./petstore.d.ts
Topics
FAQ
- What is openapi-typescript?
- Generates TypeScript types from OpenAPI 3 schemas, plus a type-safe fetch client built on those types. openapi-typescript is a monorepo with two packages for working with OpenAPI schemas in TypeScript. The main package, openapi-typescript, converts a static OpenAPI 3 schema into TypeScript type definitions, so request paths, parameters, and response bodies can be checked at compile time instead of being written by hand.
- Is openapi-typescript free to use? What license does it have?
- openapi-typescript is open source under the MIT license. Check the license terms before using it in commercial products.
- Is openapi-typescript still maintained?
- Updated within 6 months. The last commit to openapi-typescript was on Sep 25, 2026.
- What can I use openapi-typescript for?
- Generating typed API client models for a frontend app from a backend's OpenAPI file. Building a type-safe fetch client for an existing REST API. Keeping client types in sync with a changing API schema in CI.
- How do I install openapi-typescript?
- Install openapi-typescript from npm: npm i -D openapi-typescript typescript Generate types from an OpenAPI schema: npx openapi-typescript https://petstore3.swagger.io/api/v3/openapi.json -o ./petstore.d.ts
- Where can I get openapi-typescript?
- The source code and installation instructions are on GitHub: https://github.com/openapi-ts/openapi-typescript
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Go command-line tool and library that generates server boilerplate, API clients and models from OpenAPI 3.0 and 3.1 specifications.
Open-source OpenAPI/Swagger toolkit with an interactive API reference, an offline-first API client, and integrations for many web frameworks.
Generates API client SDKs, server stubs, and docs in dozens of languages and frameworks from OpenAPI specs (v2 and v3).
Java library that generates OpenAPI specifications from code annotations and JAX-RS REST APIs, supporting OpenAPI 3.x.
A Swagger/OpenAPI toolchain for .NET and ASP.NET Core that generates API specs from controllers and C# or TypeScript clients from specs.