Karate-嵌套的JSON对象模式验证导致KarateException


Feature: Test Karate schema validation
Scenario: Test nested json objects

* def response = read('tasks.json')
* def schema = { ab: "##[] string", c: "##[] string" }
* match response ==
"""
{
id: '#string',
name: '#string',
obj1: '#(schema)' ,
obj2: '##(schema)' ,
obj3: '#(schema)' ,
obj4: '#null' 

}
"""

以下是使用的json文件(tasks.json(

{
"id": "ad:p2:53456:4634:yu",
"name": "name",
"obj1": {
"ab": [
"test"
],
"c": null
},
"obj2": null,
"obj3": {
"ab": [
"tester"
],
"c": [
"t1", "t2"
]
},
"obj4": null
}

错误:com.intuit.karate.exception.KarateException:javascript评估失败:string,ReferenceError:"字符串";在第1行中未定义

我尝试了多种方法,比如:obj1:"#(^schema(",obj1:"#对象架构">

但无法解决问题。

应该是##[] #string,读取文档:https://github.com/intuit/karate#schema-验证

最新更新