BASE

openapi-typescript

openapi-typescript

Backend / API library · Free

Generates TypeScript types from an OpenAPI contract: it helps align an API client with the server description without manually copying models.

Also known as: openapi-ts/openapi-typescript; openapi-ts

Resource illustration: openapi-typescript

Open resource ↗

What you can use for free

Code and local use under MIT.

Paid features and costs

Computing resources, self-hosting, and external services are paid for separately if used.

Access and limitations

Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.

Use cases

  • Align a TypeScript client with an API contract
  • Generate types and verify client request/response compatibility

Example workflow

A possible workflow; this is not a report of hands-on testing.

Align a TypeScript client with an API contract.

Before you start

  • A data contract or HTTP workflow.
  • A project with a supported runtime.

Steps

  1. Choose the server's current OpenAPI document.
  2. Generate types and verify client request/response compatibility.
  3. Add error handling and an integration check of the result.

Check your result

  • Invalid and missing data are handled predictably.
  • Types and the actual response agree; errors are not hidden.

Choosing openapi-typescript

Align a TypeScript client with an API contract

Choose this when

  • Align a TypeScript client with an API contract
  • Generate types and verify client request/response compatibility

Requirements

  • The generator requires Node.js; the README recommends a modern version. The installation example includes openapi-typescript and typescript, with module/moduleResolution settings shown for ESNext/Bundler or NodeNext.

Things to consider

  • Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
  • Terms of use: MIT for the code; dependencies have separate licenses.
  • The current generator documents OpenAPI 3.0/3.1; OpenAPI 2.x was supported in the 5.x branch and earlier.

Frequently asked questions

What can you use for free in openapi-typescript?

Code and local use under MIT.

What additional costs might arise with openapi-typescript?

Computing resources, self-hosting, and external services are paid for separately if used.

What terms of use matter for openapi-typescript?

MIT for the code; dependencies have separate licenses.

How do you get started with openapi-typescript?

Choose the server's current OpenAPI document. Generate types and verify client request/response compatibility. Add error handling and an integration check of the result.

What does openapi-typescript produce, and does it need a running server?

The CLI converts a local or remote OpenAPI YAML/JSON schema into a TypeScript types file. Import paths and components from it, including parameter, response, and schema types. The generated types have no runtime requirement; generation needs neither Java, node-gyp, nor a running OpenAPI server. The separate openapi-fetch package uses this contract for requests.

License

MIT for the code; dependencies have separate licenses.

MIT — permissive license

You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.

License terms

Technologies and topics

  • openapi-typescript
  • API
  • Development

Sources

Other resources