jdorn / json-editor

JSON Schema Based Editor
MIT License
5.81k stars 1.08k forks source link

Validations run on load with startval and make form unusable #317

Open gmassanek opened 9 years ago

gmassanek commented 9 years ago

Issue

If I have a startval that is invalid, I the form will:

  1. Load with a validation, even if show_errors: "never" is set
  2. Render any root key, required objects uneditable.

    Example

    Schema

{
    "type": "object",
    "properties": {
        "clientId": {
            "type": "string",
            "description": "The api key that identifies your client.",
            "required": true,
            "location": "query"
        },
        "id": {
            "description": "The uuid for this deal",
            "format": "uuid",
            "required": true,
            "location": "url",
            "type": "string"
        },
        "deal": {
            "description": "Deal data",
            "required": true,
            "properties": {
                "id": {
                    "description": "The uuid for this deal",
                    "format": "uuid",
                    "type": "string"
                }
            },
            "type": "object"
        }
    }
}

startval

{
    "clientId": "1234-foobar"
}

Initial Rendering

service portal-2

I think this is not specific to startval, but more-so to how setValue works. I suspected it was an undefined vs {}, but have not had any luck poking through the source code.

Am I doing something wrong? Is it possible to set one default parameter, without clearing out all the other fields?

PS - this tool rocks. Thank you thank you.

jdorn commented 9 years ago

In your example schema, deal.id is not required, so it is not displayed by default when it's missing in the JSON value you set. Adding required: true will fix it.