Recursive schema error

Hi!
When having the simplest schema that has recursive ref inside I get:
ERROR
Maximum call stack size exceeded RangeError: Maximum call stack size exceeded


const schema : {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://smth.com/schema/site-0.12.0.schema.json",
  "title": "Site Model",
  "description": "Model of site power monitoring configuration",
  "type": "object",
  "$ref": "#/definitions/site",
  "definitions": {
    "site": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#"
          }
        }
      }
    }
  }
}
uiSchema:
  const uiSchema = {
    type: 'VerticalLayout',
    elements: [
      {
        type: 'Control',
        label: 'Site Title',
        scope: '#/properties/title', // Points to the 'title' property within the 'site' object
      },
      {
        type: 'Control',
        label: 'Children',
        scope: '#/properties/children', // Points to the 'children' array
      },
    ],
  };
   <JsonForms
        schema={schema}
        uischema={uiSchema}
        data={{}}
        renderers={vanillaRenderers} // Use material renderers
        cells={vanillaCells} // Use material cells
        onChange={({ data }) => setData(data)} // Update state on form changes
      />

same issue with materialRenderers and Cells

"@jsonforms/material-renderers": "^3.6.0",
"@jsonforms/react": "^3.6.0",
"@jsonforms/vanilla-renderers": "^3.6.0",

how can i solve this?

Hi @artishock,

This is a bug in JSON Forms. The issue happens when the root of the schema uses a $ref itself. The code does not properly handle the case and just restarts the resolving endlessly.

Until this is fixed you need to restructure the JSON Schema to not use a root level $ref, e.g.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://smth.com/schema/site-0.12.0.schema.json",
  "title": "Site Model",
  "description": "Model of site power monitoring configuration",
  "type": "object",
  "properties": {
    "title": {
      "type": "string"
    },
    "children": {
      "type": "array",
      "items": {
        "$ref": "#"
      }
    }
  }
}
1 Like

Thanks for the quick reply.
Is it known when approximately it is going to be fixed? Or it is not in priority now?

I reported the bug: #2471. I planned it in for the next minor/patch version.

1 Like