我正在使用郵遞員來驗證模式。元素的回應可以是“數字”或“空”
例如:
const schema = {
"type": "object",
"properties": {
"values": {"type": "array",
"items": [
{
"type": "object",
"properties": {
"battery_charge_state": {"type": "number"}
},
"required": [
"battery_charge_state"
]
}
]
},
},
}
pm.test("Schema validation", () => {
pm.response.to.have.jsonSchema(schema);
});
這個“battery_charge_state”有時可能是“null”
如何在郵遞員中驗證這兩種情況?
問候
uj5u.com熱心網友回復:
您可以這樣做來處理值可以是多種資料型別的情況。
"battery_charge_state": {"type": ["number", null]}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/441323.html
