【发布时间】:2021-11-12 22:36:19
【问题描述】:
我已经为 json 模式工具生成了 json 模式。我已在变量中添加了该模式。但是在验证过程中,我收到错误消息“Validate json Schema | AssertionError: expected data to meet schema but found following errors: data should be object”。
const schema = {
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://example.com/example.json",
"type": "object",
"title": "The root schema",
"description": "The root schema comprises the entire JSON document.",
"default": {},
"examples": [
{
"name": "Learn Appium Automation with Java",
"isbn": "{{isbn}}",
"aisle": "227",
"author": "{{author_name}}"
}
],
"required": ["name", "isbn", "aisle", "author"],
"properties": {
"name": {
"$id": "#/properties/name",
"type": "string",
"title": "The name schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": ["Learn Appium Automation with Java"]
},
"isbn": {
"$id": "#/properties/isbn",
"type": "string",
"title": "The isbn schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": ["{{isbn}}"]
},
"aisle": {
"$id": "#/properties/aisle",
"type": "string",
"title": "The aisle schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": ["227"]
},
"author": {
"$id": "#/properties/author",
"type": "string",
"title": "The author schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": ["{{author_name}}"]
}
},
"additionalProperties": true
};
pm.test("Validate json Schema",function(){
pm.response.to.have.jsonSchema(schema);
})
【问题讨论】:
标签: json api postman postman-collection-runner postman-testcase