Header
@tsed/schema
Usage
typescript
import { Header } from "@tsed/schema";
See /packages/specs/schema/src/types/decorators/operations/header.ts.
Overview
ts
function Header(headers: string | number | JsonHeaders, value?: string | number | JsonHeader): Function;
Description
Sets the response’s HTTP header field to value. To set multiple fields at once, pass an object as the parameter.
typescript
@Header('Content-Type', 'text/plain');
private myMethod() {}
@Status(204)
@Header({
"Content-Type": "text/plain",
"Content-Length": 123,
"ETag": {
"value": "12345",
"description": "header description"
}
})
private myMethod() {}
This example will produce the swagger responses object:
json
{
"responses": {
"204": {
"description": "Description",
"headers": {
"Content-Type": {
"type": "string"
},
"Content-Length": {
"type": "number"
},
"ETag": {
"type": "string",
"description": "header description"
}
}
}
}
}