@hono/zod-openapi and serves it with Scalar UI.
OpenAPI Endpoints
The app exposes several OpenAPI endpoints configured insrc/routes/index.ts:15:
/openapi - OpenAPI JSON Spec
Serves the OpenAPI 3.1 specification:
http://localhost:3333/openapi
/openapi/docs - Scalar UI
Serves interactive API documentation using Scalar:
http://localhost:3333/openapi/docs
Scalar Features
The Scalar UI provides:- Interactive API explorer - Test endpoints directly from the browser
- Multiple API sources - Combines app routes and BetterAuth routes
- Beautiful UI - Using the “elysiajs” theme
- Request examples - Auto-generated code samples
- Schema validation - Live validation of requests
- Response examples - View possible responses
Defining OpenAPI Routes
UsecreateRoute from @hono/zod-openapi with Zod schemas (src/routes/llms-docs.ts:41):
Schema Definition Patterns
Request Body Schema
Query Parameters
Path Parameters
Response Headers
LLMs.txt - OpenAPI for AI
The app exposes OpenAPI docs as markdown for LLMs at/llms.txt (src/routes/llms-docs.ts:128):
BetterAuth OpenAPI
The app also exposes BetterAuth routes as markdown at/llms-auth.txt (src/routes/llms-docs.ts:97):
Programmatic Access
Get OpenAPI Document
Export to File
Best Practices
- Always use
.openapi()descriptions - Provide clear descriptions for all fields - Include examples - Use
.openapi({ example: "..." })for better docs - Document error responses - Define all possible status codes
- Use meaningful summaries - Keep route summaries concise and descriptive
- Group related routes - Use path prefixes to organize routes
- Version your API - Include version in OpenAPI info
- Test in Scalar UI - Always verify docs render correctly
