@redocly/openapi-core
Version:
See https://github.com/Redocly/redocly-cli
26 lines • 1.12 kB
JavaScript
import { readFileAsStringSync } from '../../utils.js';
export const OperationDescriptionOverride = ({ operationIds }) => {
return {
Operation: {
leave(operation, { report, location }) {
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(),
});
}
}
},
},
};
};
//# sourceMappingURL=operation-description-override.js.map