Registry / http-networking / openapi-typescript-codegen

openapi-typescript-codegen

JSON →
library0.30.0jsnpmunverified

Library that generates TypeScript clients based on the OpenAPI specification. It supports various HTTP clients like Fetch, Axios, Node-Fetch, Angular, and XHR, and handles both OpenAPI v2.0 and v3.0 definitions in JSON or YAML formats. Key features included support for external references, abortable requests, and both CLI and programmatic generation. The last released version is 0.30.0. However, this package is now officially deprecated and no longer actively maintained due to time limitations from the original author. Users are strongly advised to migrate to `@hey-api/openapi-ts`, which is a maintained fork addressing previous issues and is under active development. All open PRs and issues for `openapi-typescript-codegen` were archived on May 1st, 2024, and the package is being deprecated on npm. There will be no further releases or official support for this package, making its release cadence effectively ceased.

npm install openapi-typescript-codegen
INSTALL
IMPORT
SIG · OPENAPI-TYPESCRIPT
O
openapi-typescript-codegen
http-networkingjavascriptv0.30.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

generate
import { generate } from 'openapi-typescript-codegen';
const { generate } = require('openapi-typescript-codegen');
For programmatic generation in Node.js environments. The package is ESM-first, but still supports CommonJS via transpilation. However, migration to @hey-api/openapi-ts is strongly recommended due to deprecation.
openapi (CLI)
npx openapi --input ./spec.json --output ./generated
openapi --input ./spec.json --output ./generated
The primary way to use this package is via its command-line interface, typically invoked with `npx` to ensure the correct version is run without global installation. The executable name is `openapi`.

Generates a TypeScript client using Axios for the Petstore API, placing generated files in `./generated` with custom service and model postfixes.

npx openapi \ --input https://petstore.swagger.io/v2/swagger.json \ --output ./generated \ --client axios \ --postfixServices Service \ --postfixModels Model // To use the generated client: // import { PetService } from './generated/services/PetService'; // import { AxiosHttpRequest } from './generated/core/AxiosHttpRequest'; // const httpRequest = new AxiosHttpRequest({ // baseUrl: 'https://petstore.swagger.io/v2' // }); // const petService = new PetService(httpRequest); // petService.findPetsByStatus('available') // .then(pets => console.log(pets)) // .catch(error => console.error(error));
openapi --version
Debug
Known issues
breakingThis package is officially deprecated and no longer maintained. All active development has ceased, and the author recommends migrating to the `@hey-api/openapi-ts` package.
fix
Migrate your projects to use `@hey-api/openapi-ts`. Refer to their migration guide for detailed instructions: `https://heyapi.dev/openapi-ts/migrating.html#openapi-typescript-codegen`
affects: >=0.29.0
breakingAll open Pull Requests and Issues for `openapi-typescript-codegen` were archived on May 1st, 2024. No further support, bug fixes, or new features will be implemented for this package.
fix
Any new issues or feature requests should be directed to the `@hey-api/openapi-ts` project. Migrate to the fork for continued support and development.
affects: *
gotchaDeprecated enum model generation was removed in version 0.22.0.
fix
Update your generation logic and consuming code if you relied on the deprecated enum model patterns. Ensure compatibility with the newer enum representation.
affects: <0.22.0
gotchaCompatibility issues with Axios versions 0.27.x were fixed in v0.22.0. Older versions might not generate functional Axios clients.
fix
Upgrade to `openapi-typescript-codegen` v0.22.0 or newer if using Axios 0.27.x or later to ensure correct client generation.
affects: <0.22.0
gotchaDue to issues, the internal dependency `@apidevtools/json-schema-ref-parser` was reverted to version 10.1.0 in v0.27.0. Newer features or bug fixes in later parser versions are not available.
fix
If experiencing issues with external schema references, verify that your OpenAPI specification is compatible with the behavior of `json-schema-ref-parser` v10.1.0.
affects: >=0.27.0
Errors
Common errors & fixes
Error: Required option '--input <value>' not specified
The command-line interface requires an OpenAPI specification input file or URL.
fix
Provide the input path or URL using the `--input` (or `-i`) flag: `npx openapi --input ./spec.json --output ./generated`
Error: Required option '--output <value>' not specified
The command-line interface requires an output directory where the generated client files will be written.
fix
Specify the output directory using the `--output` (or `-o`) flag: `npx openapi --input ./spec.json --output ./generated`
TypeError: generate is not a function
Attempting to call `generate` programmatically without correctly importing it or if the package is not resolved correctly in a CommonJS context.
fix
Ensure you are using `import { generate } from 'openapi-typescript-codegen';` for ESM. If in a CommonJS module, explicitly destructure, but consider that this package is deprecated and programmatic usage might be unstable; migration to `@hey-api/openapi-ts` is the long-term solution.
Upgrade
Version history
0.30.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
30
Resources
openapi-typescript-codegen — npm install openapi-typescript-codegen · libregistry