-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Fix #7052 circular reference #7068
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
base: master
Are you sure you want to change the base?
Fix #7052 circular reference #7068
Conversation
|
@char0n Can you take a look at this? Imo, this PR would mask over the cases where a circular reference still exists, but is this aligned with how |
|
Is there anything I can do to help move this along? Circular type references are valid in schema definitions. However, the current behavior when expanding a section with such a schema is that the page appears to freeze (section not loaded) because there is a max call stack exceeded issue with fromJSOrdered. This change shouldn't impact any behavior other than avoiding max call stack exceeded errors from valid schemas that have circular type references. |
@tim-lai as @kyle-apex mentioned, circular references (or in this case cyclic objects) can naturally occur in dereferenced OAS definition which is the product of resolution when using Schema Objects. @kyle-apex thanks for you work! Looking in this PR now. |
|
@kyle-apex can you please describe exact Steps Of Reproduction on fixture from #7052? I tried to reproduced on https://editor.swagger.io/ but haven't seen |
|
@char0n after far too long of an exploration (because I wasn't reproducing it using the url), I discovered that the ciruclar reference issue only occurs when the .json is loaded via a relative path like so:
That means it's probably a fix needed with regard to the differences in how the exact same swagger.json is loaded via relative path versus url. This works fine:
|
|
@kyle-apex thanks, I confirm I could reproduce. So the first thing we need to figure out what is difference between loading mechanism and where. And then fix that particular buggy place, would you agree? |
|
I can confirm this is still an issue when loading swagger specs via a relative path |
Fixes #7052 by removing processing of circular references
Description
Updated fromJSOrdered to handle circular references using the same implementation as "fromJS" in the "immutable-js" library: https://github.com/immutable-js/immutable-js/blob/master/src/fromJS.js
Rather than throw an error as "fromJS" does, this fix represents the circular reference with a Map or List depending on whether it's an array or object.
Motivation and Context
Fixes #7052
How Has This Been Tested?
Added new unit tests and manually tested against the definition provided #7052 as well as my own circular reference case.
Screenshots (if appropriate):
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests