interface RouteSchema
Since 0.1.0

Validation/documentation schemas attached to a route. Schema values are intentionally unknown here — the validation plugin narrows them (Zod schemas by default) so common stays dependency-free.

Properties

readonly
optional
body: unknown

Request body schema.

readonly
optional
query: unknown

Query parameter schema.

readonly
optional
params: unknown

Path parameter schema.

readonly
optional
headers: unknown

Header schema.

readonly
optional
response: Readonly<Record<number, unknown>>

Response schemas keyed by status code.

readonly
optional
tags: readonly string[]

OpenAPI tags.

readonly
optional
summary: string

OpenAPI operation summary.

Since 0.2.0
readonly
optional
security: readonly SecurityRequirement[]

OpenAPI security requirements for this operation, overriding any document-level default. Each entry names a scheme declared in the document's components.securitySchemes and lists the scopes it needs (empty for non-OAuth2 schemes such as HTTP bearer or API key).

An empty array is meaningful and is NOT the same as omitting the field: per the OpenAPI specification it declares the operation public, which is how a route opts out of a document-level requirement. Omitting the field leaves the operation inheriting whatever the document declares.

Declaring this does not enforce anything — authentication is enforced by middleware and guards. This describes the route for documentation and client generation.

Declaring is not the only way a document learns about authentication: a requirement can instead be DERIVED from guards branded with RouteSecurityMetadata, which is what @setu-ts/auth-plugin's guards carry. A value declared here always wins over a derived one.

Usage

import { type RouteSchema } from "common/src/index.ts";