【发布时间】:2019-03-19 12:13:13
【问题描述】:
我有一个 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"
}
注意名称属性类型是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 不支持这些验证吗?我是不是用错了规范?
【问题讨论】:
-
这可能不相关 - 但
example: 1应该在name属性定义内,而不是在对象级别。