Skip to content

covenix / Headers

Function: Headers()

Headers(schema): MethodDecorator

Defined in: src/decorators.ts:138

Validates req.headers against the given Zod object before the handler runs, and documents each property as an in: header OpenAPI parameter. The parsed (coerced) values are what @HeaderParam injects. A failure responds 400.

Header names are case-insensitive and Node lower-cases them, so the schema's keys must be lower-case (e.g. 'x-request-id'). The reserved authorization, accept, and content-type headers are still validated but omitted from the generated OpenAPI parameters (the spec handles those elsewhere).

Parameters

schema

ZodObject

Zod object schema describing the request headers.

Returns

MethodDecorator