Get Started
Generate TypeScript interfaces, REST clients, and JSON Schemas from OpenAPI specifications.
Features
- works with CLI, Node.js, or npx
- supports OpenAPI 2.0, 3.0, and 3.1 specifications
- supports both JSON and YAML input files
- generates TypeScript interfaces, REST clients, and JSON Schemas
- Fetch API, Axios, Angular, Node.js, and XHR clients available
Quick Start
The fastest way to use @hey-api/openapi-ts
is via npx
sh
npx @hey-api/openapi-ts -i path/to/openapi.json -o src/client
Congratulations on creating your first client! 🎉
Installation
sh
npm install @hey-api/openapi-ts --save-dev
sh
pnpm add @hey-api/openapi-ts -D
sh
yarn add @hey-api/openapi-ts -D
sh
bun add @hey-api/openapi-ts -D
If you want to use @hey-api/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 @hey-api/openapi-ts
in a TypeScript 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
Examples
You can view live examples on StackBlitz.