文件操作 - response-contains-header.ts
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/@redocly/openapi-core/src/rules/common/response-contains-header.ts
编辑文件内容
import { getMatchingStatusCodeRange } from '../../utils'; import type { Oas2Rule, Oas3Rule } from '../../visitors'; import type { UserContext } from '../../walk'; import type { Oas3Response } from '../../typings/openapi'; import type { Oas2Response } from '../../typings/swagger'; export const ResponseContainsHeader: Oas3Rule | Oas2Rule = (options) => { const names: Record<string, string[]> = options.names || {}; return { Operation: { Response: { enter: (response: Oas2Response | Oas3Response, { report, location, key }: UserContext) => { 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(), }); } } }, }, }, }; };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件