{"library":"oazapfts","title":"oazapfts OpenAPI TypeScript Client Generator","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install oazapfts"],"cli":{"name":"oazapfts","version":null}},"imports":["import { getPetById } from './my-generated-api';","import * as api from './my-generated-api';","import { generate } from 'oazapfts/generate';","import type { RequestOpts } from '@oazapfts/runtime';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { mkdir, writeFile } from 'node:fs/promises';\nimport { generate } from 'oazapfts/generate';\n\n// A minimal OpenAPI spec for demonstration\nconst openApiSpec = {\n  openapi: '3.0.0',\n  info: { title: 'Test API', version: '1.0.0' },\n  paths: {\n    '/items': {\n      get: {\n        operationId: 'getItems',\n        summary: 'Retrieve a list of items',\n        responses: { '200': { description: 'A list of items', content: { 'application/json': { schema: { type: 'array', items: { type: 'string' } } } } } }\n      },\n      post: {\n        operationId: 'createItem',\n        summary: 'Create a new item',\n        requestBody: {\n          required: true,\n          content: { 'application/json': { schema: { type: 'object', properties: { name: { type: 'string' } } } } }\n        },\n        responses: { '201': { description: 'Item created' } }\n      }\n    }\n  }\n};\n\nasync function main() {\n  const outputDir = './generated-client';\n  await mkdir(outputDir, { recursive: true });\n  const outputPath = `${outputDir}/api.ts`;\n\n  // Generate the client code\n  const clientCode = await generate({\n    spec: openApiSpec,\n    url: 'https://example.com/api-docs',\n    plugins: [] // You can add custom plugins here\n  });\n\n  await writeFile(outputPath, clientCode);\n  console.log(`OpenAPI client generated to ${outputPath}`);\n\n  // Example of consuming the generated API (conceptually)\n  console.log('\\n// To use the generated client (after installing @oazapfts/runtime):');\n  console.log(`// import { getItems, createItem } from './generated-client/api';`);\n  console.log(`// import { fetch } from '@oazapfts/runtime';`);\n  console.log(`// const items = await getItems();`);\n  console.log(`// await createItem({ name: 'New Item' });`);\n}\n\nmain().catch(console.error);\n","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}