oazapfts is a specialized tool for generating TypeScript API clients directly from OpenAPI or Swagger specifications. Unlike template-based generators, it leverages TypeScript's Abstract Syntax Tree (AST) API, resulting in faster code generation and highly optimized, tree-shakeable client libraries. The current stable version is 7.5.0, with frequent alpha and minor releases demonstrating active development. Key differentiators include its AST-driven approach, which avoids HTTP-specific implementation details in method signatures, grouping all optional parameters into a single object for improved ergonomics. Generated clients are self-contained in a single file and provide individually exported functions, promoting efficient tree-shaking for modern bundlers. It is primarily consumed via a command-line interface but also exposes a programmatic generation API.
npm install oazapftsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates programmatically generating a TypeScript API client from a mock OpenAPI specification and outlines how to consume the generated functions with named imports, highlighting the necessary runtime dependency.
Ensure `oazapfts` is installed as a production dependency in your project: `npm install oazapfts` or `yarn add oazapfts`.
Install the runtime package alongside oazapfts: `npm install @oazapfts/runtime` or `yarn add @oazapfts/runtime`. Ensure its version is compatible with your `oazapfts` installation.
Begin using the `--futureStripLegacyMethods` flag explicitly during generation and update your client code to use the normalized `operationId`-based method names. This prepares your codebase for the next breaking change.
Always install `oazapfts` and `@oazapfts/runtime` together and ensure their versions are compatible, ideally using exact versions or carefully managed range constraints specified by `oazapfts` itself.
Install the runtime dependency: `npm install @oazapfts/runtime` or `yarn add @oazapfts/runtime`.
Ensure your project is configured for ES modules or that your bundler correctly handles named exports. Verify that you are using named imports like `import { getPetById } from './my-generated-api';` instead of default imports or `require`.Provide a correct path to a local JSON/YAML spec file, a URL to a remote spec, or pass a valid OpenAPI object directly to the `generate` function.