json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

root array not rendered #911

Closed chemistryneil closed 7 years ago

chemistryneil commented 7 years ago

Enhancement

As a user/developer, when I pass in an schema array object i need it to display form array data

Expected behaviour

I expected to be able to pass in a schema with an array as a base object and provide a form to populate array data. Any schema with the root type of array does not render anything. even though this is a valid schema. Here is the schema i am trying to use I have checked it is valid.

    {
        "id": "http://example.com/example.json",
        "type": "array",
        "items": {
            "id": "/items",
            "type": "object",
            "properties": {
                "city": {
                    "id": "/items/properties/city",
                    "type": "string"
                },
                "name": {
                    "id": "/items/properties/name",
                    "type": "string"
                },
                "email": {
                    "id": "/items/properties/email",
                    "type": "string"
                },
                "contact": {
                    "id": "/items/properties/contact",
                    "type": "string"
                },
                "country": {
                    "id": "/items/properties/country",
                    "type": "string"
                },
                "website": {
                    "id": "/items/properties/website",
                    "type": "string"
                },
                "address1": {
                    "id": "/items/properties/address1",
                    "type": "string"
                },
                "address2": {
                    "id": "/items/properties/address2",
                    "type": "string"
                },
                "latitude": {
                    "id": "/items/properties/latitude",
                    "type": "string"
                },
                "postCode": {
                    "id": "/items/properties/postCode",
                    "type": "string"
                },
                "longitude": {
                    "id": "/items/properties/longitude",
                    "type": "string"
                },
                "telephone": {
                    "id": "/items/properties/telephone",
                    "type": "string"
                }
            }
        },
        "$schema": "http://json-schema.org/draft-04/schema#",
        "minItems": 1,
        "required": ["address1", "city", "country", "city", "latitude", "longitude"],
        "definitions": {},
        "additionalProperties": false
    }
Anthropic commented 7 years ago

@chemistryneil please read the responses on #158.

Essentially the array schema would need to be wrapped in an object schema and that isn't a high priority since it is rare that someone would want or need an array root they can't manage to wrap within an object themselves. If it ever became easy for me to change in the course of other changes then I will definitely be looking at it though, it would make life easier if we relied less on the root object.