in lib/apiScenario/bodyTransformer.ts [72:130]
private innerDeepMerge(dst: any, src: any, path: string[], inconsistentPaths: string[]): any {
if (typeof src !== typeof dst) {
inconsistentPaths.push(jp.compile(path));
return src ?? dst;
}
if (Array.isArray(dst) || Array.isArray(src)) {
if (!Array.isArray(src) || !Array.isArray(dst)) {
inconsistentPaths.push(jp.compile(path));
return src;
}
let length = dst.length;
if (dst.length !== src.length) {
inconsistentPaths.push(jp.compile(path));
if (src.length < dst.length) {
length = src.length;
}
}
const result = new Array(length);
for (let idx = 0; idx < length; idx++) {
result[idx] = this.innerDeepMerge(
dst[idx],
src[idx],
path.concat(idx.toString()),
inconsistentPaths
);
}
return result;
}
if (typeof dst === "object" && typeof src === "object") {
const result: any = { ...dst };
if (dst !== null && src !== null) {
for (const key of Object.keys(dst)) {
if (key in src) {
result[key] = this.innerDeepMerge(
dst[key],
src[key],
path.concat([key]),
inconsistentPaths
);
}
}
}
if (src !== null && dst !== null) {
for (const key of Object.keys(src)) {
if (!(key in dst)) {
result[key] = src[key];
}
}
}
return result;
}
if (dst !== src) {
inconsistentPaths.push(jp.compile(path));
}
return src;
}