70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
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
- Sign up for Cloudflare Workers. The free tier is more than enough for most use cases.
- Clone this project and install dependencies with
npm install - Run
wrangler loginto login to your Cloudflare account in wrangler - Run
wrangler deployto publish the API to Cloudflare Workers
Project structure
- Your main router is defined in
src/index.ts. - Each endpoint has its own file in
src/endpoints/. - For more information read the chanfana documentation and Hono documentation.
Development
- Run
wrangler devto start a local instance of the API. - Open
http://localhost:8787/in your browser to see the Swagger interface where you can try the endpoints. - Changes made in the
src/folder will automatically trigger the server to reload, you only need to refresh the Swagger interface.