jsonschema - Why doesn't this JSON validate against this schema? -
user_definition.json
{ "definitions": { "user": { "type": "object", "properties": { "first_name": { "type": "string" }, "last_name": { "type": "string" }, "email": { "type": "email" } }, "required": ["first_name", "last_name", "email"] } } }
user_schema.json
{ "allof": [ { "$ref": "../definitions/user_definition.json#/definitions/user" }, { "properties": { "id": { "type": "string" }, "created_at": { "type": "date-time" }, "updated_at": { "type": "date-time" } }, "required": ["id", "created_at", "updated_at"] } ] }
json
{ "id":"f10b9c6e-695c-11e5-bf98-c7cb6d8af9eb", "first_name":"johanna", "last_name":"littel", "email":"ora_turcotte@ratke.net", "created_at":"2015-10-02t23:26:00.663z", "updated_at":"2015-10-02t23:26:00.663z" }
i following error when validate document against schema:
expected {"id":"f10b9c6e-695c-11e5-bf98-c7cb6d8af9eb","first_name":"johanna","last_name":"littel","email":"ora_turcotte@ratke.net","created_at":"2015-10-02t23:26:00.663z","updated_at":"2015-10-02t23:26:00.663z"} match schema "user_response": { "allof": [ { "$ref": "../definitions/user_definition.json#/definitions/user" }, { "properties": { "id": { "type": "string" }, "created_at": { "type": "date-time" }, "updated_at": { "type": "date-time" } }, "required": ["id", "created_at", "updated_at"] } ] }
i know it's pulling in definition because if make ref invalid throw error.
the problem schema invalid. date-time
, email
not valid values type
keyword. need following instead.
{ "type": "string", "format": "date-time" }
and
{ "type": "string", "format": "email" }
Comments
Post a Comment