openapi-modifier
Version:
This package allows you to automate the process of modifying OpenAPI specifications by applying a set of predefined rules
25 lines (24 loc) • 977 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.forEachOperation = void 0;
const openapi_models_1 = require("../../openapi-models");
// TODO iterator creator
const forEachOperation = (openAPIFile, callback) => {
var _a;
const paths = (_a = openAPIFile.document) === null || _a === void 0 ? void 0 : _a.paths;
Object.keys(paths || {}).forEach((pathKey) => {
const path = paths === null || paths === void 0 ? void 0 : paths[pathKey];
const methods = Object.keys(path || {}).filter(openapi_models_1.checkIsHttpMethod);
methods.forEach((method) => {
const operationSchema = path === null || path === void 0 ? void 0 : path[method];
if (operationSchema) {
callback({
operationSchema,
method,
path: pathKey,
});
}
});
});
};
exports.forEachOperation = forEachOperation;