https://github.com/rawtoast/zenko
Bun-first TypeScript generator for OpenAPI schemas using Zod for type-safe helper functions
https://github.com/rawtoast/zenko
bun client-generator openapi typescript zod
Last synced: 2 days ago
JSON representation
Bun-first TypeScript generator for OpenAPI schemas using Zod for type-safe helper functions
- Host: GitHub
- URL: https://github.com/rawtoast/zenko
- Owner: RawToast
- License: mit
- Created: 2025-08-15T01:55:43.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2026-02-01T12:28:23.000Z (2 days ago)
- Last Synced: 2026-02-01T12:55:45.849Z (2 days ago)
- Topics: bun, client-generator, openapi, typescript, zod
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/zenko
- Size: 492 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
README
# Zenko
[](https://github.com/RawToast/zenko/actions/workflows/ci.yml)
[](https://codecov.io/gh/RawToast/zenko)
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.
## Quick Start
```bash
# One-time usage (no installation required)
bunx zenko input.yaml output.ts
```
```bash
# Or install globally
bun install -g zenko
zenko input.yaml output.ts
```
```bash
# 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"
}
```
## Features
- 🔧 **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
## Basic Usage
### Command Line
```bash
# 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
```
### Config File
```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"
}
]
}
```
### Using Generated Code
```typescript
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),
})
}
```
## Documentation
- **[Full Documentation](packages/zenko/README.md)** - Complete API reference, configuration options, and advanced usage
- **[Installation](packages/zenko/README.md#installation)** - Installation and setup guide
- **[Config File](packages/zenko/README.md#config-file)** - Configuration options and examples
- **[Open Enums](packages/zenko/README.md#open-enums)** - Handle unknown enum values gracefully
- **[Generated Output](packages/zenko/README.md#generated-output)** - Understanding the generated code
- **[Building a Generic Client](packages/zenko/README.md#building-a-generic-client)** - Creating reusable HTTP clients
- **[Examples](packages/examples/README.md)** - Example clients using fetch, undici, and ts-effect
## Requirements
- Bun 1.2.22 or higher
An npm package may be available in the future if there is demand.