persona-community-5/.pnpm-store/v3/files/04/720b121772c8cc25373d7867a3a9ffd8fd6321837463f905f86a6fbd5be65377a9965442eeb1f83bf418c52f68afc31b659a575b2d79bd72e86f768f072f66
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

59 lines
2.5 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathParamsDefined = void 0;
const pathRegex = /\{([a-zA-Z0-9_.-]+)\}+/g;
const PathParamsDefined = () => {
let pathTemplateParams;
let definedPathParams;
let currentPath;
let definedOperationParams;
return {
PathItem: {
enter(_, { key }) {
definedPathParams = new Set();
currentPath = key;
pathTemplateParams = new Set(Array.from(key.toString().matchAll(pathRegex)).map((m) => m[1]));
},
Parameter(parameter, { report, location }) {
if (parameter.in === 'path' && parameter.name) {
definedPathParams.add(parameter.name);
if (!pathTemplateParams.has(parameter.name)) {
report({
message: `Path parameter \`${parameter.name}\` is not used in the path \`${currentPath}\`.`,
location: location.child(['name']),
});
}
}
},
Operation: {
enter() {
definedOperationParams = new Set();
},
leave(_op, { report, location }) {
for (const templateParam of Array.from(pathTemplateParams.keys())) {
if (!definedOperationParams.has(templateParam) &&
!definedPathParams.has(templateParam)) {
report({
message: `The operation does not define the path parameter \`{${templateParam}}\` expected by path \`${currentPath}\`.`,
location: location.child(['parameters']).key(), // report on operation
});
}
}
},
Parameter(parameter, { report, location }) {
if (parameter.in === 'path' && parameter.name) {
definedOperationParams.add(parameter.name);
if (!pathTemplateParams.has(parameter.name)) {
report({
message: `Path parameter \`${parameter.name}\` is not used in the path \`${currentPath}\`.`,
location: location.child(['name']),
});
}
}
},
},
},
};
};
exports.PathParamsDefined = PathParamsDefined;