redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Self-referencing circular pointer

Open amine-mf opened this issue 7 months ago • 2 comments

Describe the bug

Let's consider you have an OpenAPI that contains a Self-referencing circular pointer. As of today, there is no way to "clean/preprocess" it before it is being resolved in the bundler.

I tried providing a custom implementation of externalRefResolver and using preProcessors. The first obviously can't fix the problem, from its name, it is meant for externalRefs. The latter, is called too late in the chain, it is not being applied by the resolver visitor.

In my case, I have many APIs to process and I'm looking for a clean way to do it instead of hardcoding replaces all over the place to fix the input APIs (Which are vendors provided). Is there a way to get around this using Redocly that I don't know of? What options can you offer?

To Reproduce Steps to reproduce the behavior:

The following component throws Self-referencing circular pointer which I makes sense, but it would be good to be able to fix APIs "on the fly".

components:
  schemas:
    SomeComponent:
      $ref: "#/components/schemas/SomeComponent"

Expected behavior

A way to avoid the error, using a "middleware" to apply common fixes to APIs.

Logs

OpenAPI description

Redocly Version(s) 1.17.0

Node.js Version(s)

v18.18.2

Additional context

amine-mf avatar Jul 11 '24 10:07 amine-mf