Files
core/website/src/content/docs/guides/openapi.md
T
chrnx 489aa685bb docs: host the docs at green-tea.expressive-tea.io/docs
The site hangs off the expressive-tea.io cPanel as green-tea.expressive-tea.io.
A four-level docs.green-tea.expressive-tea.io subdomain reads badly and would
need its own AutoSSL cert (the *.expressive-tea.io wildcard stops one level
up). A /docs subfolder needs no extra host, DNS, or cert — it's a path — and
is what most projects do.

So the docs site now builds with base: '/docs' (its dist/ contents drop into
the subdomain's docs/ folder in cPanel), the 77 hard-coded content links are
prefixed, and the two hero actions Starlight doesn't rewrite are fixed by
hand. Verified: /docs/ serves, / 404s, no unprefixed internal href remains.
README points at the new docs URL.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-17 10:13:10 -05:00

2.0 KiB

title, description
title description
OpenAPI Generate a structural OpenAPI 3.1 document from the route graph.

Because the request pipeline is data you can read, green-tea can project it — the same way it renders Mermaid/DOT, it emits OpenAPI.

app.openapi()

const app = createApp({ modules: [ApiModule] });
const spec = app.openapi({ title: 'My API', version: '1.0.0' });
// → OpenAPI 3.1 document

It reads the routes and handler signatures and produces, for each route:

  • the path, templated — /users/:id → /users/{id}, catch-all :path* → {path};
  • the method;
  • parameters — path params from the pattern, plus query/header params from the handler's @query / @headers / @header decorators;
  • a request body entry for routes that read @body();
  • the systematic responses — 200, a 422 when any argument is schema-validated, and 500.

WebSocket routes are omitted (they aren't request/response).

Serve it — devOpenapi

Opt in to a GET /__openapi__ endpoint that returns the document as JSON — point Swagger UI, Redoc, or a codegen client at it:

const app = createApp({ modules: [ApiModule], devOpenapi: true });
// GET /__openapi__  →  application/json

What's structural (and what isn't yet)

This is a structural spec: paths, methods, parameters, which routes take a body, and the standard error responses. What it does not include yet:

  • Request/response body schemas. Standard Schema (zod/valibot/arktype) validates input but does not expose a JSON Schema representation, so body shapes are documented generically. Parameter types default to string.

Full schemas — declared and enforced on the way out via a @Produce(schema) decorator that also validates responses — are on the roadmap for the stable release. For beta, the structural document already drives Swagger UI, client codegen, and API diffing.