UNPKG

@redocly/openapi-core

Version:

See https://github.com/Redocly/redocly-cli

26 lines 1.16 kB
import { getMatchingStatusCodeRange } from '../../utils.js'; export const ResponseContainsHeader = (options) => { const names = options.names || {}; return { Operation: { Response: { enter: (response, { report, location, key }) => { const expectedHeaders = names[key] || names[getMatchingStatusCodeRange(key)] || names[getMatchingStatusCodeRange(key).toLowerCase()] || []; for (const expectedHeader of expectedHeaders) { if (!response?.headers || !Object.keys(response?.headers).some((header) => header.toLowerCase() === expectedHeader.toLowerCase())) { report({ message: `Response object must contain a "${expectedHeader}" header.`, location: location.child('headers').key(), }); } } }, }, }, }; }; //# sourceMappingURL=response-contains-header.js.map