我的端点具有以下响应:
{
"id": 1,
"status": "ACTIVE"
}
状态的可能值如下:ACTIVE,INACTIVE,DELETED。 要检查架构,我尝试了以下操作:
* def statusValues = ["ACTIVE", "INACTIVE", "DELETED" ]
* def schema =
"""
{
"id" : #number,
"status" : '#(^*statusValues)'
}
"""
为了验证,我使用以下句子:
然后匹配response == schema
但是它不起作用。这是错误
实际:“ ACTIVE”,预期:[“ DELETED”,“ ACTIVE”,“ INACTIVE”],原因: 实际值不像列表一样
可以帮我吗?
答案 0 :(得分:1)
这可能是最简单的选择:
* def isValidStatus = function(x){ return statusValues.contains(x) }
* def schema = { id: '#number', status: '#? isValidStatus(_)' }