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
608 stars 168 forks source link

Array of objects with oneOf prop #27

Closed Rasive closed 8 years ago

Rasive commented 8 years ago

Fixing a bug where having oneOf prop on an object, in an array, causes json-forms.js to throw a hasOwnProperty of null exception. Code to reproduce:

"resources": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "type": {
            "type": "object",
            "oneOf": [
              {
                "type": "array",
                "title": "External stylesheet",
                "items": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              },
              {
                "title": "Inline stylesheet",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "selector": {
                      "type": "string"
                    },
                    "css": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string",
                            "required": true
                          },
                          "value": {
                            "type": "string",
                            "required": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      }
    }
idelvall commented 8 years ago

Thanks!