文件操作 - path-segment-plural.ts
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/@redocly/openapi-core/src/rules/common/path-segment-plural.ts
编辑文件内容
import * as pluralize from 'pluralize'; import { isPathParameter } from '../../utils'; import type { Oas3Rule, Oas2Rule } from '../../visitors'; import type { UserContext } from '../../walk'; export const PathSegmentPlural: Oas3Rule | Oas2Rule = (opts) => { const { ignoreLastPathSegment, exceptions } = opts; return { PathItem: { leave(_path: any, { report, key, location }: UserContext) { const pathKey = key.toString(); if (pathKey.startsWith('/')) { const pathSegments = pathKey.split('/'); pathSegments.shift(); if (ignoreLastPathSegment && pathSegments.length > 1) { pathSegments.pop(); } for (const pathSegment of pathSegments) { if (exceptions && exceptions.includes(pathSegment)) continue; if (!isPathParameter(pathSegment) && pluralize.isSingular(pathSegment)) { report({ message: `path segment \`${pathSegment}\` should be plural.`, location: location.key(), }); } } } }, }, }; };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件