Repolode
openapi-ts

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. 1

    Install openapi-typescript from npm

    npm i -D openapi-typescript typescript
  2. 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