我有一个OpenAPI v3规范文件,其中包含以下内容(仅显示片段):
paths:
/global/name:
get:
description: Some description
tags:
- Global settings
operationId: getGlobalSettingsName
responses:
# Response code
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/globalSettingsName'
components:
schemas:
globalSettingsName:
type: object
properties:
name:
type: integer
description: 'ID'
example: 1
required:
- name
但服务器响应是:
{
"name": "somestring"
}
注意name属性类型是integer
,在服务器响应中,它是string
(故意)但是dredd
请求通过(成功)。
dredd
不检查响应属性类型吗?
我将响应重新定义为string
(不是JSON):
responses:
# Response code
'200':
description: Successful response
content:
application/json:
schema:
type: string
和dredd
也没有抱怨。
我甚至改变了架构的属性:
globalSettingsName:
type: object
properties:
www:
type: string
description: 'some description'
example: 'somestring'
required:
- www
当预期失败时,同样(成功)的结果。
这些验证不是由dredd
支持的吗?我使用规格错了吗?
结果是当前版本(8.0.5)仅支持内容中的示例值:https://github.com/apiaryio/dredd/issues/1281