jsonforms
jsonforms copied to clipboard
Unable to use recursive schema
Describe the bug
I have a json schema which uses a $ref
as a items reference: https://pastebin.com/EJBLXZ3b (line 57)
After including it in the example and running it: I see in the dev console of my chrome:
index.js:42 Uncaught TypeError: Converting circular structure to JSON
at stringify (index.js:42)
at stringify (index.js:50)
at stringify (index.js:50)
at stringify (index.js:50)
at stringify (index.js:50)
at stringify (index.js:50)
at stringify (index.js:50)
at stringify (index.js:50)
at stringify (index.js:50)
When I remove line 57 in the schema, it works.
To Reproduce Steps to reproduce the behavior:
- Use React without redux example and use the schema shown above
- Start example
- Open dev console
- See error
Expected behavior A schema with recursion should work, or at least not fail to be used.
Browser:
- Chrome
- 76.0.3809.100 (OSX 64bit)
Used Setup:
- Framework: react + express
- RendererSet: material
Hi @jondoe1337
This is a related issue https://github.com/eclipsesource/jsonforms/issues/1476
and some discussion about cyclic refs. https://github.com/eclipsesource/jsonforms/pull/1474#issuecomment-522529303
Also which version of JSON Forms are you using? I think this error is caused by a change introduced in #1474 but that's not included in latest stable release v2.3.0
Hi @Lily418 sorry for overseeing those issues.
I use v2.3.1
I'd try v2.3.0 to avoid that error, but be aware of Stefan's comment https://github.com/eclipsesource/jsonforms/pull/1474#issuecomment-522529303 this may be an issue depending on your use case.
The non-redux version of the react-seed partially works for me with your schema when, ironically, the ref parser is configured in the redux store with { refParserOptions: { dereference: { circular: "ignore" } } }
as the last argument of the init
action.
There seems to be some unintended interaction between the examples in the seed. Also the standalone version seems to hiccup on some of the nested objects while the redux version has no problems there.
We'll need to investigate the behavior of our example seed and how JSON Forms behaves with your schema in a pure non-redux app. Note that you can also pass the refParser options to the JsonForms
component when needed, although it seems to worsen the behavior in the seed app.
As @Lily418 mentioned we are actively working on improving the resolve behavior for recursive and circular refs. We'll take a look at your schema as one of the testcases.
This should be fixed with the updates we did to ref-resolving for JSON Forms 3.0. Feel free to reopen in case this error still occurs.