Pass an optional meta field on any route() call to attach structured usage examples, extra descriptive copy, or free-form x-*extensions. Daloy validates every example against your route’s Standard Schema at build time and emits the same payload into OpenAPI (examples on the request body, examples on the matching response, x-daloy-examples on the operation) and into the daloy inspect --ai dump that codegen agents and SDK builders consume.
Additive and non-breaking. Existing routes keep working unchanged, meta is optional everywhere.
One meta block, many consumers
single sourceroute({ meta })examples, description, x-* extensions
build timeSchema validationevery example checked vs Standard Schema
specOpenAPI 3.1examples + x-daloy-examples on the operation
codegenHey API + LLM toolingexamples carry into SDK docstrings
The meta block is the one place you author examples. Daloy validates them against your schemas, then surfaces the same payload into OpenAPI and the AI dump that codegen agents consume.
summary / description / tags: augment the route-level fields of the same name. Route-level values win when both are set; tags are de-duplicated and concatenated.
examples: record of named { summary?, description?, request?: { params?, query?, headers?, body? }, response?: { status, body?, headers? } } pairs. Every field is optional individually; pass only the parts you want documented.
extensions: free-form bag emitted onto the OpenAPI Operation Object. Keys without an x- prefix are prefixed automatically for spec compliance.
Build-time validation
Run pnpm daloy inspect --check (or call runContractTests(app) from your tests). For every named example, Daloy validates:
request.body / request.query / request.params / request.headers against the matching schema on request when both sides exist.
response.body against the response schema for the declared status; an unknown status code is itself an error.
Mismatches fail the contract run so the OpenAPI document never publishes a sample that does not match its schema.
OpenAPI surfacing
The same shape is folded into the generated OpenAPI 3.1 document so Swagger UI, Scalar, and Hey API see your examples without any extra wiring:
Dump the whole route catalog, with JSON Schema for every input and output and every meta.examples entry, as a single, self-describing JSON document. It is the format Daloy recommends for feeding to an LLM or a codegen agent that needs more than the OpenAPI spec alone:
bash
pnpm daloy inspect --ai > routes.jsonpnpm daloy inspect --ai --json | jq '.routes[].operationId'# Emit YAML instead of JSON - typically ~30% smaller, which matters# when you are pasting the dump into an LLM system prompt.pnpm daloy inspect --ai --yaml > routes.yamlpnpm daloy inspect --ai --format yaml > routes.yaml# Combine with --tag/--method to scope the dumppnpm daloy inspect --ai --tag Books
Both --ai and --openapi accept --yaml (shorthand) or --format yaml. The emitter is a tiny built-in YAML 1.2 serializer with no runtime dependencies. Because YAML drops braces, commas, and most quotes, the dump is typically about 30% smaller than the equivalent pretty-printed JSON, a meaningful saving when the file becomes part of an LLM system prompt.