{"id":11497,"library":"openapi-typescript-codegen","title":"OpenAPI TypeScript Codegen","description":"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.","status":"deprecated","version":"0.30.0","language":"javascript","source_language":"en","source_url":"https://github.com/ferdikoomen/openapi-typescript-codegen","tags":["javascript","openapi","swagger","generator","typescript","yaml","json","fetch","xhr"],"install":[{"cmd":"npm install openapi-typescript-codegen","lang":"bash","label":"npm"},{"cmd":"yarn add openapi-typescript-codegen","lang":"bash","label":"yarn"},{"cmd":"pnpm add openapi-typescript-codegen","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const { generate } = require('openapi-typescript-codegen');","symbol":"generate","correct":"import { generate } from 'openapi-typescript-codegen';"},{"note":"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`.","wrong":"openapi --input ./spec.json --output ./generated","symbol":"openapi (CLI)","correct":"npx openapi --input ./spec.json --output ./generated"}],"quickstart":{"code":"npx openapi \\\n  --input https://petstore.swagger.io/v2/swagger.json \\\n  --output ./generated \\\n  --client axios \\\n  --postfixServices Service \\\n  --postfixModels Model\n\n// To use the generated client:\n// import { PetService } from './generated/services/PetService';\n// import { AxiosHttpRequest } from './generated/core/AxiosHttpRequest';\n\n// const httpRequest = new AxiosHttpRequest({\n//   baseUrl: 'https://petstore.swagger.io/v2'\n// });\n// const petService = new PetService(httpRequest);\n\n// petService.findPetsByStatus('available')\n//   .then(pets => console.log(pets))\n//   .catch(error => console.error(error));","lang":"typescript","description":"Generates a TypeScript client using Axios for the Petstore API, placing generated files in `./generated` with custom service and model postfixes."},"warnings":[{"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`","message":"This 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.","severity":"breaking","affected_versions":">=0.29.0"},{"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.","message":"All 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.","severity":"breaking","affected_versions":"*"},{"fix":"Update your generation logic and consuming code if you relied on the deprecated enum model patterns. Ensure compatibility with the newer enum representation.","message":"Deprecated enum model generation was removed in version 0.22.0.","severity":"gotcha","affected_versions":"<0.22.0"},{"fix":"Upgrade to `openapi-typescript-codegen` v0.22.0 or newer if using Axios 0.27.x or later to ensure correct client generation.","message":"Compatibility issues with Axios versions 0.27.x were fixed in v0.22.0. Older versions might not generate functional Axios clients.","severity":"gotcha","affected_versions":"<0.22.0"},{"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.","message":"Due 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.","severity":"gotcha","affected_versions":">=0.27.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Provide the input path or URL using the `--input` (or `-i`) flag: `npx openapi --input ./spec.json --output ./generated`","cause":"The command-line interface requires an OpenAPI specification input file or URL.","error":"Error: Required option '--input <value>' not specified"},{"fix":"Specify the output directory using the `--output` (or `-o`) flag: `npx openapi --input ./spec.json --output ./generated`","cause":"The command-line interface requires an output directory where the generated client files will be written.","error":"Error: Required option '--output <value>' not specified"},{"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.","cause":"Attempting to call `generate` programmatically without correctly importing it or if the package is not resolved correctly in a CommonJS context.","error":"TypeError: generate is not a function"}],"ecosystem":"npm"}