Package Manager Installation
Install@hey-api/openapi-ts as a dev dependency using your preferred package manager:
The
-E flag (or --save-exact) pins the exact version. This is recommended due to the package being in initial development (see Versioning).Requirements
OpenAPI TypeScript has minimal requirements:- Node.js:
>=20.19.0 - TypeScript:
>=5.5.3(peer dependency)
Versioning
To safely upgrade:- Pin exact versions using the
-Eflag when installing - Review migration notes before upgrading
- Test thoroughly after upgrading
Migration Notes
We publish detailed migration notes for every breaking release. You might not be impacted by a breaking change if you don’t use the affected features. Check the migration guide when upgrading:Adding to package.json Scripts
After installation, add a script to yourpackage.json to make the CLI easily accessible:
package.json
Basic Setup
After installation, create a configuration file to define your code generation settings.Configuration File
OpenAPI TypeScript supports multiple configuration file formats. The most common isopenapi-ts.config.ts:
Running the Generator
With the configuration file in place, run the generator:Programmatic Usage
You can also use OpenAPI TypeScript programmatically in Node.js:script.ts
- Custom build pipelines
- Dynamic configuration
- Integration with other tools
- CI/CD workflows
Verification
Verify the installation by checking the version:Project Structure
Here’s a typical project structure after installation:TypeScript Configuration
Ensure yourtsconfig.json is configured for ESM modules:
tsconfig.json
Watch Mode
During development, you can enable watch mode to automatically regenerate code when your OpenAPI specification changes:openapi-ts.config.ts
Multiple Configurations
You can generate multiple clients from different OpenAPI specifications:openapi-ts.config.ts
Next Steps
Configuration
Learn about all configuration options
Quick Start
Generate your first client
Plugins
Explore available plugins
HTTP Clients
Choose your HTTP client