persona-community-5/.pnpm-store/v3/files/e6/d621aaa48b5a8b0611b63f4fc5d9af8ef494107aaef0d83f7a2906e9f04e4b3b057ce707488c2e9090c6f78997d35faab9d066aedaab95bed3eec2448932cd
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

28 lines
986 B
Plaintext

import type { Oas3Rule, Oas2Rule } from '../../visitors';
import type { Oas2Definition, Oas2Tag } from '../../typings/swagger';
import type { Oas3Definition, Oas3Tag, Oas3_1Definition } from '../../typings/openapi';
import type { UserContext } from '../../walk';
export const TagsAlphabetical: Oas3Rule | Oas2Rule = ({ ignoreCase = false }) => {
return {
Root(
root: Oas2Definition | Oas3Definition | Oas3_1Definition,
{ report, location }: UserContext
) {
if (!root.tags) return;
for (let i = 0; i < root.tags.length - 1; i++) {
if (getTagName(root.tags[i], ignoreCase) > getTagName(root.tags[i + 1], ignoreCase)) {
report({
message: 'The `tags` array should be in alphabetical order.',
location: location.child(['tags', i]),
});
}
}
},
};
};
function getTagName(tag: Oas2Tag | Oas3Tag, ignoreCase: boolean): string {
return ignoreCase ? tag.name.toLowerCase() : tag.name;
}