voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.52k stars 242 forks source link

"required" array in sub schema not being checked #325

Closed coslett closed 8 years ago

coslett commented 8 years ago

Please correct me if I'm wrong but it seems that schemas within schemas are not having their "required" array validated.

{
    "schemaOne": {
        "title": "schemaOne",
        "type": "array",
        "schemaTwo": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "identifier": {
                    "type": "number",
                    "maxlength": 1
                    "description": "A unique identifier"
                }
            },
            "required": [
                "identifier"
            ]
        },
        "required": [
            "schemaTwo"
        ]
    }
}

If was to use an empty object for "schemaTwo" no error would be thrown. If I was to provide "identifier" with a a 2 digit number I would have an exception thrown. Also if I was to remove schemaTwo entirely I would get an exception thrown as well.

I've reviewed JSON Draft Schema 4 documentation and it does support a schema within a schema and the schema does pass validation.

Any insight would be greatly appreciated.

coslett commented 8 years ago

Detected the issue in my schema, sorry for any confusion.