crickford / vue-json-schema-form

VueJS library for generating forms from JSON schemas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support root-level array type

josestbernard opened this issue · comments

Nice lib ❤️ , are you considering adding support to arrays at root level as well?

Use case:
When the json schema root type is array we should be able to have add/remove whole blocks of properties, same as right now it's working when a sub-type is array of objects

Example schema

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/root.json",
  "title": "root",
  "type": "array",
  "items": {
    "title": "Person",
    "type": "object",
    "$id": "#/items",
    "properties": {
      "firstName": {
        "type": "string",
        "title": "First Name",
        "description": "The person's first name.",
        "example": "John"
      },
      "lastName": {
        "type": "string",
        "title": "Last Name",
        "description": "The person's last name.",
        "example": "Doe"
      },
      "nickNames": {
        "type": "array",
        "title": "Nicknames",
        "items": {
          "type": "string",
          "example": "j-dough"
        }
      },
      "address": {
        "type": "object",
        "title": "Address",
        "properties": {
          "lineOne": {
            "type": "string",
            "title": "Address line 1",
            "example": "Address line 1"
          },
          "lineTwo": {
            "type": "string",
            "title": "Address line 2",
            "example": "Address line 2"
          },
          "postalCode": {
            "type": "string",
            "title": "Postal code",
            "example": "Postal code"
          }
        }
      },
      "age": {
        "title": "Age",
        "description": "Age in years which must be equal to or greater than zero.",
        "type": "integer",
        "minimum": 0
      }
    },
    "required": [
      "firstName"
    ]
  }
}