Karate jsonschema的所有键值都不匹配

Karate jsonschema的所有键值都不匹配,karate,Karate,我的jsonschema如下所示: { "id": 0, "rc": "51", "product": { "code": "28", "label": "PLN", "type": "electricity", "ops": "PLN", "nominal": 50000 }, "cust_id": "01428800200", "order_id": "",

我的jsonschema如下所示:

{
    "id": 0,
    "rc": "51",
    "product": {
        "code": "28",
        "label": "PLN",
        "type": "electricity",
        "ops": "PLN",
        "nominal": 50000
    },
    "cust_id": "01428800200",
    "order_id": "",
    "ref_no": "2033930693200733",
    "amount": 50000,
    "price": 50000,
    "created": -62135596800
}
这是我的模式验证

{
  "id": "#number",
  "rc": "#string",
  "product": {
    "code": "#string",
    "label": "#string",
    "type": "#string",
    "ops": "#string",
    "nominal": "#number"
  },
  "cust_id": "#string",
  "order_id": "#string",
  "ref_no": "#string",
  "amount": "#number",
  "price": "#number",
  "created": "#number? _ < 0"
}
{
“id”:“#编号”,
“rc”:“#字符串”,
“产品”:{
“代码”:“#字符串”,
“标签”:“#字符串”,
“类型”:“#字符串”,
“ops”:“字符串”,
“名义”:“数量”
},
“客户id”:“#字符串”,
“订单id”:“#字符串”,
“参考号”:“字符串”,
“金额”:“#编号”,
“价格”:“编号”,
“已创建”:“#编号?0”
}

但我得到了一条消息,原因是:所有键值都不匹配,但我认为我的模式是正确的,所以有人能帮我吗???

这对我来说很有效,你的脚本中一定有错误。将以下内容粘贴到新的要素文件中,并查看它是否适合您自己:

* def response = 
"""
{
    "id": 0,
    "rc": "51",
    "product": {
        "code": "28",
        "label": "PLN",
        "type": "electricity",
        "ops": "PLN",
        "nominal": 50000
    },
    "cust_id": "01428800200",
    "order_id": "",
    "ref_no": "2033930693200733",
    "amount": 50000,
    "price": 50000,
    "created": -62135596800
}
"""
* def schema =
"""
{
  "id": "#number",
  "rc": "#string",
  "product": {
    "code": "#string",
    "label": "#string",
    "type": "#string",
    "ops": "#string",
    "nominal": "#number"
  },
  "cust_id": "#string",
  "order_id": "#string",
  "ref_no": "#string",
  "amount": "#number",
  "price": "#number",
  "created": "#number? _ < 0"
}
"""
* match response == schema
*def响应=
"""
{
“id”:0,
“rc”:“51”,
“产品”:{
“代码”:“28”,
“标签”:“PLN”,
“类型”:“电”,
“ops”:“PLN”,
“名义”:50000
},
“客户id”:“01428800200”,
“订单号”:“,
“参考号”:“2033930693200733”,
“金额”:50000,
“价格”:50000美元,
“已创建”:-62135596800
}
"""
*定义模式=
"""
{
“id”:“#编号”,
“rc”:“#字符串”,
“产品”:{
“代码”:“#字符串”,
“标签”:“#字符串”,
“类型”:“#字符串”,
“ops”:“字符串”,
“名义”:“数量”
},
“客户id”:“#字符串”,
“订单id”:“#字符串”,
“参考号”:“字符串”,
“金额”:“#编号”,
“价格”:“编号”,
“已创建”:“#编号?0”
}
"""
*匹配响应==架构

这对我有用,你的脚本中一定有错误。将以下内容粘贴到新的要素文件中,并查看它是否适合您自己:

* def response = 
"""
{
    "id": 0,
    "rc": "51",
    "product": {
        "code": "28",
        "label": "PLN",
        "type": "electricity",
        "ops": "PLN",
        "nominal": 50000
    },
    "cust_id": "01428800200",
    "order_id": "",
    "ref_no": "2033930693200733",
    "amount": 50000,
    "price": 50000,
    "created": -62135596800
}
"""
* def schema =
"""
{
  "id": "#number",
  "rc": "#string",
  "product": {
    "code": "#string",
    "label": "#string",
    "type": "#string",
    "ops": "#string",
    "nominal": "#number"
  },
  "cust_id": "#string",
  "order_id": "#string",
  "ref_no": "#string",
  "amount": "#number",
  "price": "#number",
  "created": "#number? _ < 0"
}
"""
* match response == schema
*def响应=
"""
{
“id”:0,
“rc”:“51”,
“产品”:{
“代码”:“28”,
“标签”:“PLN”,
“类型”:“电”,
“ops”:“PLN”,
“名义”:50000
},
“客户id”:“01428800200”,
“订单号”:“,
“参考号”:“2033930693200733”,
“金额”:50000,
“价格”:50000美元,
“已创建”:-62135596800
}
"""
*定义模式=
"""
{
“id”:“#编号”,
“rc”:“#字符串”,
“产品”:{
“代码”:“#字符串”,
“标签”:“#字符串”,
“类型”:“#字符串”,
“ops”:“字符串”,
“名义”:“数量”
},
“客户id”:“#字符串”,
“订单id”:“#字符串”,
“参考号”:“字符串”,
“金额”:“#编号”,
“价格”:“编号”,
“已创建”:“#编号?0”
}
"""
*匹配响应==架构