短时间内针对特定客户设置的
Find a file
2025-06-25 16:32:14 +08:00
.vscode feat: 创建api项目 2025-06-25 08:41:49 +08:00
src feat: 完成定制 2025-06-25 16:31:44 +08:00
.envrc Initial commit 2025-06-25 00:30:58 +00:00
.gitignore Initial commit 2025-06-25 00:30:58 +00:00
flake.lock Initial commit 2025-06-25 00:30:58 +00:00
flake.nix Initial commit 2025-06-25 00:30:58 +00:00
package-lock.json feat: 创建api项目 2025-06-25 08:41:49 +08:00
package.json feat: 创建api项目 2025-06-25 08:41:49 +08:00
README.md feat: 创建api项目 2025-06-25 08:41:49 +08:00
tsconfig.json feat: 创建api项目 2025-06-25 08:41:49 +08:00
wrangler.jsonc feat: 完成定制 2025-06-25 16:31:44 +08:00

Cloudflare Workers OpenAPI 3.1

This is a Cloudflare Worker with OpenAPI 3.1 using chanfana and Hono.

This is an example project made to be used as a quick start into building OpenAPI compliant Workers that generates the openapi.json schema automatically from code and validates the incoming request to the defined parameters or request body.

Get started

  1. Sign up for Cloudflare Workers. The free tier is more than enough for most use cases.
  2. Clone this project and install dependencies with npm install
  3. Run wrangler login to login to your Cloudflare account in wrangler
  4. Run wrangler deploy to publish the API to Cloudflare Workers

Project structure

  1. Your main router is defined in src/index.ts.
  2. Each endpoint has its own file in src/endpoints/.
  3. For more information read the chanfana documentation and Hono documentation.

Development

  1. Run wrangler dev to start a local instance of the API.
  2. Open http://localhost:8787/ in your browser to see the Swagger interface where you can try the endpoints.
  3. Changes made in the src/ folder will automatically trigger the server to reload, you only need to refresh the Swagger interface.