本文へスキップ

chanfana

活発
cloudflare/chanfana

Cloudflare Workers 上の Hono、itty-router などのルーター向けに、OpenAPI 3 / 3.1 のスキーマ生成とリクエスト検証を提供します。

GitHub で見る
スター
767
フォーク
71
ウォッチ
767
未解決の Issue
55

この紹介文は現在英語版のみです。

Overview

chanfana (previously known as itty-router-openapi) adds OpenAPI 3 and 3.1 schema generation and request validation to existing routers such as Hono and itty-router. It is built as a lightweight library for Cloudflare Workers, but runs on any runtime the underlying router supports.

You define endpoints as classes with Zod schemas, and chanfana validates incoming requests, infers TypeScript types, and serves interactive API documentation automatically.

Key Features

  • OpenAPI 3 and 3.1 schema generation and validation
  • Zod v4 schemas with full TypeScript inference for query, path, headers, and body
  • Class-based endpoints that keep schema, validation, and handler together
  • Works with existing apps: wrap a Hono or itty-router app without touching old routes
  • Auto-generated interactive API docs served from your Worker
  • CLI (npx chanfana) that boots your Worker with wrangler dev and exports schema.json — handy in CI
  • AI coding skills to help assistants write chanfana endpoints

Getting Started

Scaffold a complete example — a Task API with Hono, D1, and Zod, including CRUD endpoints, tests, and docs at /api/docs:

npm create cloudflare@latest -- --template https://github.com/cloudflare/chanfana/tree/main/template

Or add it to an existing project:

npm i chanfana

Wrap your Hono app with fromHono(...), define endpoints by extending OpenAPIRoute with a Zod schema, and register them like normal routes. Requests that don’t match the schema are rejected with a clear validation error before your handler runs.

Use Cases

  • Typed, documented REST APIs on Cloudflare Workers
  • Adding OpenAPI docs to an existing Hono or itty-router project incrementally
  • Generating client SDKs from a schema exported in CI

License

MIT License.

共通のカテゴリとタグで順位付けした、似たオープンソースプロジェクトです。

すべての SDK プロジェクト →