Skip to content

Translating cycles in ApiDOM represented as cyclic directed tree to RefElements #3921

Open
@char0n

Description

@char0n

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 },
        );

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions