Bun-first TypeScript generator for OpenAPI specifications that creates Zod schemas, type-safe path functions, and operation objects.
Unlike most OpenAPI generators, Zenko does not create a client. Instead you are free to use your own fetch/undici wrapper or library of choice.
# One-time usage (no installation required)
bunx zenko input.yaml output.ts# Or install globally
bun install -g zenko
zenko input.yaml output.ts# Or as a script in your package.json
bun add -d zenko
# Then in your package.json, note the `-b` flag to run the command with Bun and not Node.
"scripts": {
"generate": "bun -b zenko --config resources/zenko.config.json"
}- 🔧 Zod Schema Generation - Runtime-validated schemas from OpenAPI
- 🛣️ Type-safe Path Functions - Build API paths with proper TypeScript types
- 📋 Operation Objects - Path functions, request validation, and response types
- 🧰 Operation Type Helpers - Reusable type definitions for building generic clients
- 🔄 Dependency Resolution - Automatic topological sorting eliminates "used before declaration" errors
- 🔓 Open Enums - Accept unknown enum values gracefully with configurable prefixes
- ⚡ CLI & Programmatic API - Use via command line or import as a library
# Generate from OpenAPI spec
zenko petstore.yaml api-types.ts
# Enable strict validation
zenko api.yaml types.ts --strict-dates --strict-numeric
# Use config file for multiple specs
zenko --config zenko.config.json{
"$schema": "https://raw.githubusercontent.com/RawToast/zenko/refs/heads/master/packages/zenko/zenko-config.schema.json",
"schemas": [
{
"input": "api.yaml",
"output": "api.gen.ts"
}
]
}import { paths, authenticateUser } from "./api.gen"
// Type-safe path building
const path = paths.getUserById({ userId: "123" })
// → "/users/123"
// Request validation with Zod
const validation = authenticateUser.request(requestData)
if (validation.success) {
const response = await fetch(baseUrl + authenticateUser.path(), {
method: "POST",
body: JSON.stringify(validation.data),
})
}- Full Documentation - Complete API reference, configuration options, and advanced usage
- Installation - Installation and setup guide
- Config File - Configuration options and examples
- Open Enums - Handle unknown enum values gracefully
- Generated Output - Understanding the generated code
- Building a Generic Client - Creating reusable HTTP clients
- Examples - Example clients using fetch, undici, and ts-effect
- Bun 1.2.22 or higher
An npm package may be available in the future if there is demand.