persona-community-5/.pnpm-store/v3/files/ec/71a8727c9c8e695a29efb049f26854c7fc5afeead0368a9fa8a8efd390809b0eac54ee80693f2ff92af4a606dd624722197b752b15e89c2986e8863ca7cf0b
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.2 KiB
Plaintext

import { readFileAsStringSync } from '../../utils';
import type { Oas3Decorator, Oas2Decorator } from '../../visitors';
import type { Oas2Operation } from '../../typings/swagger';
import type { Oas3Operation } from '../../typings/openapi';
import type { UserContext } from '../../walk';
export const OperationDescriptionOverride: Oas3Decorator | Oas2Decorator = ({ operationIds }) => {
return {
Operation: {
leave(operation: Oas2Operation | Oas3Operation, { report, location }: UserContext) {
if (!operation.operationId) return;
if (!operationIds)
throw new Error(
`Parameter "operationIds" is not provided for "operation-description-override" rule`
);
const operationId = operation.operationId;
if (operationIds[operationId]) {
try {
operation.description = readFileAsStringSync(operationIds[operationId]);
} catch (e) {
report({
message: `Failed to read markdown override file for operation "${operationId}".\n${e.message}`,
location: location.child('operationId').key(),
});
}
}
},
},
};
};