文件操作 - security-defined.js
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/@redocly/openapi-core/lib/rules/common/security-defined.js
编辑文件内容
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SecurityDefined = void 0; const SecurityDefined = (opts) => { const referencedSchemes = new Map(); const operationsWithoutSecurity = []; let eachOperationHasSecurity = true; let path; return { Root: { leave(root, { report }) { for (const [name, scheme] of referencedSchemes.entries()) { if (scheme.defined) continue; for (const reportedFromLocation of scheme.from) { report({ message: `There is no \`${name}\` security scheme defined.`, location: reportedFromLocation.key(), }); } } if (root.security || eachOperationHasSecurity) { return; } else { for (const operationLocation of operationsWithoutSecurity) { report({ message: `Every operation should have security defined on it or on the root level.`, location: operationLocation.key(), }); } } }, }, SecurityScheme(_securityScheme, { key }) { referencedSchemes.set(key.toString(), { defined: true, from: [] }); }, SecurityRequirement(requirements, { location }) { for (const requirement of Object.keys(requirements)) { const authScheme = referencedSchemes.get(requirement); const requirementLocation = location.child([requirement]); if (!authScheme) { referencedSchemes.set(requirement, { from: [requirementLocation] }); } else { authScheme.from.push(requirementLocation); } } }, PathItem: { enter(pathItem, { key }) { path = key; }, Operation(operation, { location, key }) { const isException = opts.exceptions?.some((item) => item.path === path && (!item.methods || item.methods?.some((method) => method.toLowerCase() === key))); if (!operation?.security && !isException) { eachOperationHasSecurity = false; operationsWithoutSecurity.push(location); } }, }, }; }; exports.SecurityDefined = SecurityDefined;
修改文件时间
将文件时间修改为当前时间的前一年
删除文件