Skip to content

OpenAPI Specification

Generate the spec:

pnpm run generate-openapi

Output: openapi.json in project root.

How It Works

  1. Define schema in your route file using Zod
  2. Register the schema and endpoint with the registry
  3. Import the route in app/openapi/index.ts
  4. 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.