Open
Description
We have to first think where this code should belong to. It looks like a apidom-core transformer, as the operation is fairly simple and no external resolution is involved.
I've created a pseudo-code that looks like this:
const ancestors = []
const idents = IdentityManager();
const test = visit(
dereferencedElement,
{
ObjectElement(element: any, key, parent, path, ancestors) {
if (ancestors.includes(element)) {
console.dir(element.element);
element.id = idents.identify(element);
if (isMemberElement(parent)) {
parent.value = new RefElement(`urn:apidom:${toValue(element.id)}`);
} else if (Array.isArray(parent)) {
parent[key] = new RefElement(`urn:apidom:${toValue(element.id)}`);
}
return false;
}
},
},
{ detectCycles: false },
);