OpenAPI TypeScript Codegen

0.30.0 · deprecated · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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));

view raw JSON →