邮递员测试-对象的架构

时间:2018-09-14 15:42:55

标签: json testing postman

我有一个回复正文:

{
    "Id": 15,
    "Name": "Carrier1",
    "Fein": "Fein1",
    "McNumber": "McNumber1",
    "DotNumber": "DotNumber1",
    "Address": {
        "Street": "Street1",
        "City": "City1",
        "ZipPostalCode": null,
        "StateName": "AA (Armed Forces Americas)",
        "StateAbbr": "AA",
        "ContactName": null,
        "ContactPhone": null,
        "ContactFaxNumber": null,
        "ContactEmail": null
    }
}

我使用Postman,并希望描述测试中的验证模式:

const schema = {
  "required": ["Id"],
  "properties": {
    "Id": {
      "type": "integer",
    },
    "Name": {
      "type": "string",
    },
    "Fein": {
      "type": "string",
    },
    "McNumber": {
      "type": "string",
    },
    "DotNumber": {
      "type": "string",
    },
    "Address": {
        "type" : {
            "properties": {
                "Street": {
                "type": "string",
                },            
            },
        }
    }
  }
};

var carrier = JSON.parse(responseBody);
tests["Carrier is valid"] = tv4.validate(carrier, schema);

但不起作用。验证它应该只是对象:

"Address": {
    "type" : "object"
    }

工作正常。如何描述细节?

0 个答案:

没有答案