OpenAPI Generator
Generate type-safe API clients from OpenAPI specifications.
What is create-freestyle-fetch?
create-freestyle-fetch is a CLI tool that transforms OpenAPI specifications into fully type-safe TypeScript API clients powered by the @freestylejs/fetch library.
It eliminates manual API client code and keeps your client in sync with your API specification.
The generated code uses Zod v4 for runtime validation and provides complete type inference for requests and responses.
Key Features
Simple CLI
Generate clients with a single command. No configuration required.
Type-Safe Output
Generates TypeScript code with full type inference for all API operations.
Zod Validation
Automatic runtime validation using Zod schemas for request and response data.
Authentication
Built-in support for Bearer, Basic, and API Key authentication schemes.
Fetch Integration
Generated clients use the @freestylejs/fetch fluent builder API.
Quick Example
Generate a fully typed API client from your OpenAPI specification:
npx create-freestyle-fetch generate \
--input ./api-spec.json \
--output ./src/apiUse the generated client in your code:
import { createClient } from './api'
// Initialize the client
const client = createClient({
baseUrl: 'https://api.example.com'
})
// Fully typed request and response
const user = await client.users.$userId.GET({
params: { userId: '123' }
})
// TypeScript knows the shape of `user`
console.log(user.name, user.email)