UNPKG

@apideck/portman

Version:

Port OpenAPI Spec to Postman Collection, with contract & variation tests included

35 lines 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.overwriteCollectionValues = void 0; var tslib_1 = require("tslib"); var utils_1 = require("../../utils"); var overwriteCollectionValues = function (collectionJson, dictionary) { Object.entries(dictionary).map(function (_a) { var e_1, _b; var _c = tslib_1.__read(_a, 2), target = _c[0], value = _c[1]; try { for (var _d = tslib_1.__values(Object.entries(collectionJson)), _e = _d.next(); !_e.done; _e = _d.next()) { var _f = tslib_1.__read(_e.value, 2), key = _f[0], val = _f[1]; if (Array.isArray(val)) { val.map(function (obj) { return (0, exports.overwriteCollectionValues)(obj, dictionary); }); } else if (val && (0, utils_1.isObject)(val)) { (0, exports.overwriteCollectionValues)(val, dictionary); } else if (typeof val === 'string' && val.includes(target)) { collectionJson[key] = value; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_e && !_e.done && (_b = _d.return)) _b.call(_d); } finally { if (e_1) throw e_1.error; } } }); return collectionJson; }; exports.overwriteCollectionValues = overwriteCollectionValues; //# sourceMappingURL=overwriteCollectionValues.js.map