我正在将 dredd 从 1.08 升级到最新版本,与此同时,我正在尝试验证我们的 api 文档,它是用实时测试 api 用蓝图编写的,但它失败了。
由于测试是针对实时 api 运行的,因此从 api 返回的响应包含与模糊打印文档中指定的值不同的值。我从 dredd 收到以下错误。
有人可以帮我弄清楚吗?:)
正文:在'/data/email'没有枚举匹配:“dredd_testzz@keyflow.se”
正文:在'/data/firstName'没有枚举匹配:“狙击手”
正文:在'/data/lastName'没有枚举匹配:“狼”
正文:在'/data/verified'没有枚举匹配:false
## `ResponseSchema` (object)
+ email: `john.doe@example.com` (string, required) - Email address
+ firstName: John (string, required) - First name
+ lastName: Doe (string, required) - Last name
+ verified: true (boolean, required) - True
# Group Account
## Login [/login/?]
Login user
### Login [POST]
Authentication required.
+ Request (application/json)
+ Attribute (LoginInputSchema)
+ Response 200 (application/json; charset=UTF-8)
+ Attribute
+ status: 200 (number, required, fixed)
+ data (ResponseSchema, required, fixed)
dredd 生成的 JSON Schema 如下
bodySchema: {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"status": {
"type": "number",
"enum": [
200
]
},
"data": {
"type": "object",
"properties": {
"email": {
"type": "string",
"enum": [
"john.doe@example.com"
],
"description": "Email address of the guest."
},
"firstName": {
"type": "string",
"enum": [
"John"
],
"description": "First name of the guest."
},
"lastName": {
"type": "string",
"enum": [
"Doe"
],
"description": "Last name of the guest."
},
"verified": {
"type": "boolean",
"enum": [
true
],
"description": "The user is verified or not"
},
},
"required": [
"email",
"firstName",
"lastName",
"verified",
],
"additionalProperties": false
}
},
"required": [
"status",
"data"
]
}