Get Started ​
openapi-ts allows you to create TypeScript interfaces, REST clients, and schemas from an OpenAPI specification.
Features ​
- generate TypeScript interfaces from OpenAPI v2.0, v3.0, and v3.1 specifications
- support JSON or YAML input files
- handle external references using JSON Schema $Ref Parser
- generate fetch, axios, angular, node.js, or xhr REST clients
- usable with CLI, Node.js, or npx
- abortable requests through cancellable promise pattern
Quick Start ​
The fastest way to use openapi-ts is via npx
sh
npx @hey-api/openapi-ts -i path/to/openapi.json -o src/clientCongratulations on creating your first client! 🎉
Installation ​
sh
npm install @hey-api/openapi-ts --save-devsh
pnpm add @hey-api/openapi-ts -Dsh
yarn add @hey-api/openapi-ts -Dsh
bun add @hey-api/openapi-ts -DIf you want to use openapi-ts with CLI, add a script to your package.json file
json
"scripts": {
"openapi-ts": "openapi-ts"
}You can also generate your client programmatically by importing openapi-ts in a .ts file.
ts
import { createClient } from '@hey-api/openapi-ts'
createClient({
input: 'path/to/openapi.json',
output: 'src/client',
})WARNING
You need to be running Node.js v18 or newer
