OpenAPI Specification
Generate the spec:
pnpm run generate-openapi
Output: openapi.json in project root.
How It Works
- Define schema in your route file using Zod
- Register the schema and endpoint with the registry
- Import the route in
app/openapi/index.ts - Generate the spec
Adding an Endpoint
// app/routes/users.tsx
import { z } from "zod/v4";
import { registry } from "../openapi/registry.js";
// 1. Define schema
export const UserSchema = z.object({
id: z.string().uuid(),
name: z.string(),
});
// 2. Register schema and endpoint
registry.register("User", UserSchema);
registry.registerPath({
method: "get",
path: "/users/{id}",
request: {
params: z.object({ id: z.string().uuid() }),
},
responses: {
200: {
description: "User found",
content: { "application/json": { schema: UserSchema } },
},
},
});
// 3. Use schema for validation in handler
export async function loader({ params }) {
// ...
}
Then add the import in app/openapi/index.ts:
import "../routes/users.js";
Runtime Access
The spec is served at /registration/api/openapi.json.