Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
char0n opened this issue Mar 13, 2024 · 0 comments
Labels
ApiDOM enhancement New feature or request

Comments

@char0n
Copy link
Member

char0n commented Mar 13, 2024

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 },
        );
@char0n char0n added enhancement New feature or request ApiDOM labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ApiDOM enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant