我正在尝试通过Karate json模式验证来验证json响应。我已经以多种方式使用了很多次,在这个简单的示例中,我无法理解到底出了什么问题。这是我得到的答复:
* def response =
"""
[{
"id" : "1111",
"surname" : "Debby",
"name" : "Johns",
"status" : "MARRIED",
"rooms" : [{
"number" : "2",
"state" : "clean",
"owner" : {
"name" : "Mrs Johns",
"address" : "New York",
"birth_date" : 1555493518,
"birth_place" : "Jersey",
"phone_number" : "078******1"
},
"keys" : [{
"id" : "aaa",
"color" : "blue"
}]
}],
"creation_date" : 1555493458,
"left" : false
}]
"""
这是架构:
* def ownerSchema =
"""
{
name: '#string',
address: '##string',
birth_date: '##number',
birth_place: '##string',
phone_number: '##string'
}
"""
* def keySchema =
"""
{
id: '#string',
color: '#string'
}
"""
* def roomSchema =
"""
{
number: '#string',
state: '#string',
owner: "#('##(ownerSchema)')",
keys: '##[] keySchema'
}
"""
* def clientSchema =
"""
{
id: '#string',
surname: '##string',
name: '#string',
status: '#string',
creation_date: '#number',
left: '#boolean',
rooms: '#[] roomSchema'
}
"""
当我尝试验证它时: *匹配每个响应== clientSchema
错误是:路径$ [0] ['rooms']中缺少属性 这让我发疯,我找不到。
答案 0 :(得分:0)
此版本将从0.9.2开始运行。