jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Unable to use recursive schema

Open jondoe1337 opened this issue 5 years ago • 4 comments

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:

  1. Use React without redux example and use the schema shown above
  2. Start example
  3. Open dev console
  4. 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

jondoe1337 avatar Aug 28 '19 14:08 jondoe1337

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

Lily418 avatar Aug 28 '19 14:08 Lily418

Hi @Lily418 sorry for overseeing those issues.

I use v2.3.1

jondoe1337 avatar Aug 28 '19 14:08 jondoe1337

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.

Lily418 avatar Aug 28 '19 14:08 Lily418

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.

sdirix avatar Aug 28 '19 16:08 sdirix

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.

sdirix avatar Nov 08 '22 21:11 sdirix