Open jorgemk85 opened 4 months ago
Hi @jorgemk85,
Your definition contains cycles and even though https://editor-next.swagger.io/ (SwaggerEditor@5) is based on ApiDOM which can handle cycles easily, we still seeing that error.
The issue is that for resolving
the definitions, we currently use dereference
algorithm (reference removal). Dereferencing can create cycles (circular references) and cycles cannot be serialized into JSON or YAML. In order to resolve this issue properly we need to use bundling
algorithm. We've already started some initial work on bundling in https://github.com/swagger-api/apidom/issues/692.
What we can do for now to mitigate the issue (before we have bundling) is to run the dereferencing in replace mode and use circularReplacer
to make the circular reference absolute and skip resolving it.
Hello @char0n,
Thank you for your reply.
I am using this "https://generator3.swagger.io/index.html#/clients/generate" endpoint to procedurally transform my spec files into "html2" static websites. Could you please indicate how to specify the dereferencing property in the request body? I have tried the following without making any difference:
{
"lang":"html2",
"spec":"...",
"specURL":null,
"type":"CLIENT",
"codegenVersion":"V3",
"options":{
"dereference":{
"circular":"replace"
}
}
}
Q&A (please complete the following information)
Content & configuration
Example Swagger/OpenAPI definition:
Swagger-UI configuration options:
Describe the bug you're encountering
Generator Client for "html2" is failing to render the schemas when they have circular references. Also, SwaggerEditor fails when trying to "Download Resolved JSON/YAML". The error shown is "Maximum call stack size exceeded".
To reproduce...
Steps to reproduce the behavior: Scenario 1:
Scenario 2:
Expected behavior
Scenario 1: Browser's console doesn't display any "Maximum call stack size exceeded" errors, meaning that it processes Circular References correctly and schemas are rendered properly. (Consider using a dictionary of the visited nodes).
Scenario 2: Browser throws a file to download that includes the resolved YAML file.
Screenshots
Scenario 1:
![image](https://github.com/swagger-api/swagger-ui/assets/46335029/5854feaa-9f0b-4ace-8b27-99c0ab247d8a)
Scenario 2:![image](https://github.com/swagger-api/swagger-ui/assets/46335029/bf4e739f-7e91-4a14-83d4-511a8dbccd3d)
Additional context or thoughts
A similar problemas was resolved in Issue #8537, but they exclusively impacted the Editor's UI and the issue persists in (at least) this other functions. @char0n your input is greatly appreciated. The provided spec file was created specifically to replicate this issue.