brutusin / json-forms

JSON Schema to HTML form generator, supporting dynamic subschemas (on the fly resolution). Extensible and customizable library with zero dependencies. Bootstrap add-ons provided
http://brutusin.org/json-forms
Apache License 2.0
606 stars 168 forks source link

recursive $ref iteration #126

Open Shairp opened 6 years ago

Shairp commented 6 years ago

Hello I have json schema with recursive $ref iteration, for example:


{
    "definitions": {
        "TPNode": {
            "title": "TPNode",
            "description": "TPNode",
            "type": "object",
            "properties": {
                "selector": {
                    "type": "string",
                    "required": true
                }, 
                "attributes": {
                    "type": "array",
                    "items": {
                        "title": "Attribute",
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string"
                            },
                            "value": {
                                "type": "string"
                            }
                        }
                    }
                },
                "children": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/TPNode"
                    }
                },
                "events": {
                    "type": "array",
                    "items": { 
                        "title": "Event",
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string"
                            },
                            "handler": {
                                "type": "object"
                            },
                            "dependencies": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "$ref": "#/definitions/TPNode"
}

when I am using this project with the json schema above then the create form button not working and I am getting "maximum call stack size exceeded" in the browser DevTool can some one help me and fix this bug?

Shai

OYE93 commented 5 years ago

hi did you solve this problem?

marcmalerei commented 5 years ago

I am getting the same error.

{ "$schema": "http://json-schema.org/draft-03/schema#", "$ref": "#/definitions/data", "definitions" : { "data" : { "type" : "object", "properties" : { "menu" : { "$ref" : "#/definitions/menu" } }, "required" : ["menu"] }, "menu" : { "title" : "menu", "type" : "array", "items" : { "$ref" : "#/definitions/item" }, "minItems" : 1 }, "item" : { "title" : "menuitem", "type" : "object", "properties" : { "item" : { "type" : "string", "title" : "itemtext", "default" : "item" }, "href" : { "type" : "string", "title" : "itemhref", "default" : "/de" }, "menu" : { "title" : "menu", "oneOf" : [ { "title" : "no childs", "type":"null" }, { "$ref" : "#/definitions/menu" } ] } } } } }