使用空手道对JSON进行模式验证



早上好

我刚刚开始使用JSON,所以我知道这是一个非常基本的问题,有人能指出我在尝试验证事件和问题方面做错了什么吗?

Scenario: Get Entity Result with BASIC privledges, return userCanDismiss 'False'
* def appParams = '{"dhd":{"dhdPermissions":"BASIC"},"podId":"eedev-inta"}}}'
* def bfToken = TestUtils.getBFTokenWithAppParams(null, 769870979, 0, 'BF_ADMIN', appParams)
* print 'bfToken -> ', bfToken
* configure headers = { BFToken: #(bfToken), pod:{"podId":"eedev-inta"} }
* def schema =
"""
{
"data": {
"ids": [ "#string"
]
},
"_links":{},
"_embedded": {
"validationEventResults": [{
"data": {
"validationProblemStats": [{
"occurrences": "#ignore",
"problemId": "#string"
}
]
}
}
]
}
}
"""
Given path '/entities/' + externalEntityId + '/types/' + entityType + '/validation-event-results'
When method get
Then status 200
And match response contains schema

似乎id字段已成功验证,但我的文件在尝试验证出现和问题时失败。

注意,我已经简化并更改了名称。请将此作为参考,阅读文档,然后找到解决方案:https://github.com/intuit/karate#schema-validation

* def stat = { occurrences: '#ignore', problemId: '#string' }
* def eventResult = { data: { validationProblemStats: '#[] stat' } }
* def schema = { embedded: { validationEventResults: '#[] eventResult' } }

* def response = 
"""
{ "embedded": { 
"validationEventResults": [
{ "data": {
"validationProblemStats": []
} 
}
]
} 
}
"""
* match response == schema

最新更新