persona-community-5/.pnpm-store/v3/files/9f/fbea3c80b165f9e72e0ff591850d308ae4dea29548834b3d954096ec2fdc92ec9d61927c68922e6c7597674c35106b4a0ee72b01d72fd6e0fdb90cf7eaaf34
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

31 lines
1.1 KiB
Plaintext

import type { Oas3Rule, Oas2Rule } from '../../visitors';
import type { Oas2PathItem } from '../../typings/swagger';
import type { Oas3PathItem } from '../../typings/openapi';
import type { UserContext } from '../../walk';
const defaultOrder = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace'];
export const PathHttpVerbsOrder: Oas3Rule | Oas2Rule = (opts: any) => {
const order: string[] = (opts && opts.order) || defaultOrder;
if (!Array.isArray(order)) {
throw new Error('path-http-verbs-order `order` option must be an array');
}
return {
PathItem(path: Oas2PathItem | Oas3PathItem, { report, location }: UserContext) {
const httpVerbs = Object.keys(path).filter((k) => order.includes(k));
for (let i = 0; i < httpVerbs.length - 1; i++) {
const aIdx = order.indexOf(httpVerbs[i]);
const bIdx = order.indexOf(httpVerbs[i + 1]);
if (bIdx < aIdx) {
report({
message: 'Operation http verbs must be ordered.',
location: { reportOnKey: true, ...location.child(httpVerbs[i + 1]) },
});
}
}
},
};
};