I am having a hard time understanding why an instance would not validate. Here is my schema:
{
"definitions" : {
"message_id_type" : {
"type" : "object",
"properties" : {
"msgtype" : { "type" : "string" },
"msgkey" : { "type" : "string" }
}
},
"contact" : {
"type": "object",
"allOf" : [
{ "$ref" : "#/definitions/message_id_type" },
{ "properties" : {
"last_name" : { "type" : "string" },
"first_name" : { "type" : "string" } }
}],
"additionalProperties" : false
},
"address" : {
"type" : "object",
"allOf" : [
{ "$ref" : "#/definitions/message_id_type" },
{ "properties" : {
"street" : { "type" : "string" },
"zip" : { "type" : "string" } }
}],
"additionalProperties" : false
}
},
"oneOf" : [
{ "$ref" : "#/definitions/contact" },
{ "$ref" : "#/definitions/address" }
]
}
Here is the instance I would like to validate:
{
"msgtype" : "test",
"last_name" : "teter",
"first_name" : "trter"
}
and this is the error I am getting doing so (with heroku app):
[ {
"level" : "fatal",
"schema" : {
"loadingURI" : "#",
"pointer" : "/definitions/message_id_type/properties/msgtype"
},
"instance" : {
"pointer" : "/msgtype"
},
"domain" : "validation",
"message" : "validation loop: schema \"#/definitions/message_id_type/properties/msgtype\" visited twice for pointer \"/msgtype\" of validated instance",
"alreadyVisited" : "#/definitions/message_id_type/properties/msgtype",
"instancePointer" : "/msgtype",
"validationPath" : [ "#", "#/oneOf/0", "#/definitions/contact/allOf/0", "#/definitions/message_id_type/properties/msgtype", "#/definitions/contact/allOf/1", "#/definitions/contact/allOf/1/properties/first_name", "#/definitions/contact/allOf/1/properties/last_name", "#/oneOf/1", "#/definitions/address/allOf/0" ],
"info" : "other messages follow (if any)"
} ]
Note if I change the schema to this:
{
"definitions" : {
"message_id_type" : {
"type" : "object",
"properties" : {
"msgtype" : { "type" : "string" },
"msgkey" : { "type" : "string" }
}
},
"contact" : {
"type": "object",
"properties" : {
"msgtype" : { "type" : "string" },
"msgkey" : { "type" : "string" },
"last_name" : { "type" : "string" },
"first_name" : { "type" : "string" } },
"additionalProperties" : false
},
"address" : {
"type" : "object",
"properties" : {
"msgtype" : { "type" : "string" },
"msgkey" : { "type" : "string" },
"street" : { "type" : "string" },
"zip" : { "type" : "string" } },
"additionalProperties" : false
}
},
"oneOf" : [
{ "$ref" : "#/definitions/contact" },
{ "$ref" : "#/definitions/address" }
]
}
the instance above starts to validate. All I have done is to inline a refrenced type. Anyone have any input on this?