Skip to content

Overview

Stratal generates a complete OpenAPI 3.0 specification from the Zod schemas you already use for validation. One schema drives both runtime validation and your API documentation, so the two can never drift apart.

Every @Route-decorated controller method is automatically included in a generated OpenAPI spec. The OpenAPIModule is registered as core infrastructure during application startup, so there is nothing to set up for basic usage.

Out of the box, you get:

  • Automatic OpenAPI 3.0 spec generated from your Zod schemas and route decorators.
  • Interactive API docs served by Swagger UI at /api/docs.
  • JSON spec endpoint at /api/openapi.json for importing into tools like Postman or Insomnia.
  • Built-in security scheme definitions for bearer tokens, API keys, and session cookies.
  • Common error responses (400, 401, 403, 404, 409, 500) auto-included on every route.
  • Unreferenced schema pruning so the spec only contains schemas your routes actually use.

The flow from code to interactive docs looks like this:

  1. You define Zod schemas and attach them to controller methods via the @Route decorator.
  2. At startup, Stratal registers each route with @hono/zod-openapi, which builds the full OpenAPI document.
  3. When a request hits the JSON spec endpoint, Stratal filters out hidden routes, prunes unused schemas, and returns the final spec.
  4. The docs UI reads that spec and renders an interactive API reference.

Head to Setup to learn how to customize the OpenAPI spec metadata, paths, and security schemes.