Docs / OpenAPI

OpenAPI

One command turns your models and routes into an OpenAPI 3.1 spec.

Added in 1.0

Hopak already knows your API: models declare fields, types, and constraints; CRUD routes are generated from models. hopak openapi turns that knowledge into an OpenAPI 3.1 document — zero annotations required.

hopak openapi                 # prints to stdout
hopak openapi --out api.json  # writes a file

Pipe it straight into a client generator:

hopak openapi | bunx openapi-typescript /dev/stdin -o api.d.ts

What you get

Custom routes

Hand-written routes appear with a generic 200 response. To document one against a model, set openapi in defineRoute:

export const GET = defineRoute({
  handler: async (ctx) => { /* ... */ },
  openapi: { model: 'post', kind: 'read', summary: 'Fetch one post' },
});