jsonschema - JSON Schema to validate multiple similar objects inside an array -


this question has answer here:

what keyword use in json schema if want elements of array (which objects) follow same schema?

example:

"data":  [     { //validated       "id": 1,       "name": "bob",       "ready": "not ready"     },     { //validated       "id": 2,       "name": "steve",       "ready": "ready"     },     { //not validated, missing "ready"       "id": 3,       "name": "ted"     } ] 

specify "data" object type array , indicate required elements in each item.

{   "type": "object",   "properties": {     "data": {       "type": "array",       "items": {         "type": "object",         "properties": {           "id": {             "type": "integer"           },           "name": {             "type": "string"           },           "ready": {             "type": "string"           }         },         "required": [           "id",           "name",           "ready"         ]       }     }   },   "required": [     "data"   ] } 

Comments