in packages/extensions/core/src/lib/plugins/merger.ts [392:460]
visitPaths(paths: ProxyObject<Record<string, oai.PathItem>>, nodes: Iterable<Node>) {
for (const { key, value, pointer, children } of nodes) {
const uid = `path:${this.opCount++}`;
// tag the current pointer with a the new location
const originalLocation = `${(<DataHandle>this.currentInput).originalFullPath}#${pointer}`;
this.refs[originalLocation] = `#/paths/${uid}`;
// for testing with local refs
this.refs[`#${pointer}`] = `#/paths/${uid}`;
// create a new pathitem (use an index# instead of the path)
const operation = this.newObject(paths, `${uid}`, pointer);
const metadata = {
value: {
apiVersions: [this.current.info && this.current.info.version ? this.current.info.version : ""], // track the API version this came from
filename: [this.currentInputFilename], // and the filename
path: key, // and here is the path from the operation.
originalLocations: [originalLocation],
},
pointer,
};
operation["x-ms-metadata"] = metadata;
// now, let's copy the rest of the operation into the operation object
for (const child of children) {
// check if operation if not is common and should be put in each one.
switch (child.key) {
case "get":
case "put":
case "post":
case "delete":
case "options":
case "head":
case "patch":
case "trace":
{
const childOperation = this.newObject(paths, `${uid}.${child.key}`, pointer);
childOperation["x-ms-metadata"] = cloneDeep(metadata);
this.copy(childOperation, child.key, child.pointer, child.value);
if (value.parameters) {
if (childOperation[child.key].parameters) {
childOperation[child.key].parameters.unshift(
...cloneDeep(value.parameters).filter((x: { in: string; name: string }) => {
for (const param of childOperation[child.key].parameters) {
if (x.in === param.in && x.name === param.name) {
return false;
}
}
return true;
}),
);
} else {
childOperation[child.key].parameters = cloneDeep(value.parameters);
}
}
}
break;
// case 'parameters':
// they are placed at the beginning of the array parameters per operation.
default:
// for now skipping until we support all OA3 features.
break;
}
}
}
}