$ recombobulate _
home / tips / generate-a-typed-api-client-from-an-openapi-spec
0

Generate a Typed API Client from an OpenAPI Spec

bagwaa @bagwaa · Mar 26, 2026 · Workflows
generate-a-typed-api-client-from-an-openapi-spec

Your OpenAPI spec is already the source of truth for your API — so let it generate your client code too. Claude reads the spec, understands the endpoint shapes, and produces a client that fits your existing codebase style.

Read openapi.yaml and generate a fully-typed TypeScript API client using
the native fetch API. Group methods by resource tag, export each group as
a named export, and infer all request/response types from the spec schemas.

Claude handles the parts that make hand-written clients tedious: translating schemas into TypeScript interfaces, building URL params correctly, handling authentication headers, and wiring up error types from the spec's error responses.

# PHP with Guzzle
Generate a PHP API client from openapi.yaml using Guzzle 7.
Create one class per resource tag, add PHPDoc blocks for each method,
and use typed DTOs for request bodies and responses.

# With a specific HTTP library
Read the Stripe OpenAPI spec at stripe-openapi.json and generate a typed
client using axios. Add retry logic on 429 responses and map all error
codes to typed exceptions.

# Minimal approach
From openapi.yaml, generate just the TypeScript types and a simple
fetch wrapper for the /users and /orders endpoints.

Your spec is already written — let Claude turn it into working, typed client code automatically.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago