persona-community-5/.pnpm-store/v3/files/8c/d11f8b3e7591e184ad9cd182bf600c0bc1bf70f8f30695d063e1ae702cd96f6df6ed9073b12b92e8168ec47987eb7f1dfd030cd200c2be517dd45f9a768d7f
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

32 lines
1.1 KiB
Plaintext

import type { Oas3Rule, Oas2Rule } from '../../visitors';
import type { Oas2Definition, Oas2Operation } from '../../typings/swagger';
import type { Oas3Definition, Oas3_1Definition, Oas3Operation } from '../../typings/openapi';
import type { UserContext } from '../../walk';
export const OperationTagDefined: Oas3Rule | Oas2Rule = () => {
let definedTags: Set<string>;
return {
Root(root: Oas2Definition | Oas3Definition | Oas3_1Definition) {
definedTags = new Set((root.tags ?? []).map((t) => t.name));
},
Operation(operation: Oas2Operation | Oas3Operation, { report, location }: UserContext) {
if (operation?.tags) {
for (let i = 0; i < operation.tags.length; i++) {
if (!definedTags.has(operation.tags[i])) {
report({
message: `Operation tags should be defined in global tags.`,
location: location.child(['tags', i]),
});
}
}
} else {
report({
message: `Operation tags should be defined`,
location: location.key(),
});
}
},
};
};