rjsf-team / react-jsonschema-form

A React component for building Web forms from JSON Schema.
https://rjsf-team.github.io/react-jsonschema-form/
Apache License 2.0
14.38k stars 2.19k forks source link

Exception thrown while using recursive schema definition #452

Closed b1r3k closed 7 years ago

b1r3k commented 7 years ago

Prerequisites

Description

Current implementation is not able to handle recursive schema

Steps to Reproduce

  1. Make recursive schema like this:
{
    "definitions": {
        "TPNode": {
            "title": "TPNode",
            "description": "TPNode",
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "children": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/TPNode"
                    }
                }
            }
        }
    },
    "$ref": "#/definitions/TPNode"
}
  1. Try to render

See fiddle: https://jsfiddle.net/b1r3k/dssabb76/2/

Expected behavior

Form should be rendered according to valid schema as done for example here

Actual behavior

RangeError exception is being thrown

RangeError: Maximum call stack size exceeded
toIdSchema
webpack:///./~/react-jsonschema-form/lib/utils.js?:475:18
toIdSchema
webpack:///./~/react-jsonschema-form/lib/utils.js?:483:12
toIdSchema
webpack:///./~/react-jsonschema-form/lib/utils.js?:491:22
toIdSchema
webpack:///./~/react-jsonschema-form/lib/utils.js?:480:12
toIdSchema
webpack:///./~/react-jsonschema-form/lib/utils.js?:483:12
toIdSchema
webpack:///./~/react-jsonschema-form/lib/utils.js?:491:22

Version

Current release (0.41.2)

gpietro commented 6 years ago

I still have this problem with version 1.0.0.

{
  "title": "Maximum call stack",
  "description": "Example to reproduce the error.",
  "$ref": "#/definitions/Person",
  "type": "object",
  "definitions": {
    "Person": {
      "properties": {
        "firstName": {
          "type": "string",
          "title": "First name"
        },
        "lastName": {
          "type": "string",
          "title": "Last name"
        },
        "address": {
          "title": "Hello",
          "type": "object",
          "$ref": "#/definitions/Address"
        }
      }
    },
    "Address": {
      "properties": {
        "street": {
          "type": "string",
          "title": "address2"
        },
        "resident": {
          "type": "object",
          "$ref": "#/definitions/Person"
        }
      }
    }
  }
}
yuvi116 commented 5 years ago

did any one got the solution for recursive schema