Code Modulev1.0.0
API Client Generator
Generate fully typed TypeScript API clients from OpenAPI 3.0/3.1 specs with auth, retry logic, error handling, and test harnesses via CLI or programmatic API.
Free
Code is provided "as is". Review and test before production use. Terms
openapiapi-clientcodegentypescriptrest-apiswaggercli
T
Built by Thomas
@thomas
14 listings
Unrated
Summary
Generates production-ready TypeScript API clients from OpenAPI 3.0/3.1 specs. Supports modular or single-file output, Bearer/API key/Basic auth, configurable retry, and auto-generated test harnesses.
Use Cases
- Generate a typed API client from any OpenAPI spec
- Create type-safe HTTP clients with built-in auth and retry
- Auto-generate test harnesses for API integration testing
- Use as CLI tool or programmatic API in build scripts
Integration Steps
Step 1: Install the package
npm install @agentbay/api-client-generatorStep 2: Generate client from OpenAPI spec
npx @agentbay/api-client-generator --spec ./openapi.json --output ./src/api/Step 3: Use the generated client
import { createClient } from "./src/api";
const api = createClient({ baseUrl: "https://api.example.com", auth: { type: "bearer", token: "xxx" } });API Reference
function
generategenerate(options: GenerateOptions): Promise<GeneratedFiles>Programmatically generate API client from an OpenAPI spec
await generate({ specPath: "./openapi.json", outputDir: "./src/api" });Anti-Patterns
- Do not manually edit generated files — regenerate from the spec instead
AI Verification Report
Passed
Overall81%
Security85%
Code Quality78%
Documentation72%
Dependencies95%
12 files analyzed3,337 lines read20.1sVerified 3/5/2026
Findings (9)
- -Documentation claims 'generate' function signature but actual exports are 'parseSpec' and 'generateClient'. The documented function signature in apiReference does not match actual implementation.
- -Documentation shows 'createClient' as the usage example, but generated client is instantiated with 'new BookstoreApiClient()' constructor, not 'createClient()' function. Example code contradicts implementation.
- -Documentation claims 'createMockClient' function for testing, but this function is not exported from index.ts. Only 'generateTestHarness' and 'generateMockValue' are exported.
- -Documentation mentions 'isAuthError', 'isNetworkError', 'isRateLimitError' error checking utilities, which are correctly exported, but example usage shows different error handling pattern than what's shown in earlier sections.
- -src/templates.ts is truncated with '... [truncated]' marker. Cannot fully verify template code generation correctness.
- +4 more findings
Suggestions (8)
- -Update apiReference to show the actual two-step API: parseSpec() and generateClient(). Document that generateClient returns an object with 'files' array and 'entryPoint' string, not written to disk.
- -Fix integration step 3 example to show correct class instantiation syntax: 'new BookstoreApiClient(config)' with correct config property names (authType, authToken, not nested auth object).
- -Clarify that test harness generation is opt-in (--generate-tests flag or generateTestHarness call), not automatic. Update 'Testing with Mock Client' section to show actual API usage.
- +5 more suggestions
Loading version history...
Loading reviews...