UNPKG

@tsed/schema

Version:
20 lines (19 loc) 686 B
import { execMapper, registerJsonSchemaMapper } from "../../registries/JsonSchemaMapperContainer.js"; export function operationResponseMapper(jsonResponse, options = {}) { const response = execMapper("map", [jsonResponse], options); if (jsonResponse.status === 204) { delete response.content; } if (response.headers) { Object.entries(response.headers).forEach(([key, { type, ...props }]) => { response.headers[key] = { ...props, schema: { type } }; }); } return response; } registerJsonSchemaMapper("operationResponse", operationResponseMapper);