openapi-gui icon indicating copy to clipboard operation
openapi-gui copied to clipboard

Recursive schema reference errors

Open dadardy opened this issue 6 years ago • 6 comments

Loving the openapi-gui so far and would like to use it, but some of my schemas have recursive references at the child level and at the grandchild level. This causes callstack errors in Chrome and "too many recursion" errors in Firefox when clicking a schemas edit icon.

Any chance you can add in child schema tracking to detect recursion and render recursive schema children, grandchildren, etc... with a placeholder like they do in redoc?

Thanks!

dadardy avatar Feb 27 '19 17:02 dadardy

I've built a webpack bundle from reftools which has better recurse and dereferencing routines, so I will move over to that.

I don't suppose you have a short repro test case you could share?

Thanks for reporting!

MikeRalphson avatar Feb 27 '19 19:02 MikeRalphson

Wow! Thanks for the quick response.

Here is a sample with multiple recursive references. Let me know if that helps.

Cheers!

dadardy avatar Feb 27 '19 23:02 dadardy

Not sure if the sample will come through on my email reply. Here it is again just in case.

openapi.json.txt

dadardy avatar Feb 27 '19 23:02 dadardy

Ok, it was the jsonEditor component itself which couldn't handle the recursive schemas, so now we replace the recursive properties with $refs again (after dereferencing them originally). I still don't think it's the ideal component for editing / viewing complex schemas, but I'm still looking for a good replacement.

It would be great if you could retest and confirm the crash is gone.

MikeRalphson avatar Feb 28 '19 04:02 MikeRalphson

Hi Mike,

It loads now without any recursion errors. But any object that gets opened up, the $ref paths get all messed up now when downloading the schema after viewing it in the jsonEditor.

See the User component in the schema below. The $ref on properties of the User components are now "#/items/oneof/...." instead of "#/components/..."

openapi.json.txt

Thanks again for looking into this recursion issue!

dadardy avatar Feb 28 '19 07:02 dadardy

OK, I've moved the 'fix' to another branch and reverted it on master for now, until the $ref path is fixed and tested. Shouldn't take long as the routine used has an option for this.

MikeRalphson avatar Feb 28 '19 09:02 MikeRalphson