dredd yml 的多个请求
Multiple requests with dredd yml
对我的 API 使用 node dredd。
我选择使用 yml 文件,因为这是我的团队熟悉的标准。
这是一个我们可以正常运行的示例片段:
/api/station/{id}:
get:
produces:
- application/json; charset=utf-8
parameters:
- name: id
in: path
required: true
type: string
description: DynamoDB ID of the station to edit
x-example: 'daf04a00-c3bf-11e7-a913-b76623d265c4'
responses:
200:
description: Returns a single station
schema:
$ref: '#/definitions/station'
我想我可以猜到如何定义备用响应对象,我假设只需添加到对象中,例如:
responses:
200:
description: Returns a single station
schema:
$ref: '#/definitions/station'
422:
description: Failed validation
有一个如何将多个请求发送到同一端点的示例。但这是针对 API 蓝图格式而不是 yaml。
有谁知道如何使用 yaml 格式将多个请求传递到同一个端点?我看不到有关如何执行此操作的任何文档
在您链接的文档部分的正下方有 Testing non-2xx Responses with Swagger:
The Swagger format allows to specify multiple responses for a single operation.
By default Dredd tests only responses with 2xx
status codes. Responses with other
codes are marked as skipped and can be activated in hooks - see Testing non-2xx Responses with Swagger.
Default responses are ignored by Dredd. Also, as of now,
only application/json
media type is supported in produces
and consumes
.
Other media types are skipped.
对我的 API 使用 node dredd。 我选择使用 yml 文件,因为这是我的团队熟悉的标准。
这是一个我们可以正常运行的示例片段:
/api/station/{id}:
get:
produces:
- application/json; charset=utf-8
parameters:
- name: id
in: path
required: true
type: string
description: DynamoDB ID of the station to edit
x-example: 'daf04a00-c3bf-11e7-a913-b76623d265c4'
responses:
200:
description: Returns a single station
schema:
$ref: '#/definitions/station'
我想我可以猜到如何定义备用响应对象,我假设只需添加到对象中,例如:
responses:
200:
description: Returns a single station
schema:
$ref: '#/definitions/station'
422:
description: Failed validation
有一个如何将多个请求发送到同一端点的示例。但这是针对 API 蓝图格式而不是 yaml。
有谁知道如何使用 yaml 格式将多个请求传递到同一个端点?我看不到有关如何执行此操作的任何文档
在您链接的文档部分的正下方有 Testing non-2xx Responses with Swagger:
The Swagger format allows to specify multiple responses for a single operation. By default Dredd tests only responses with
2xx
status codes. Responses with other codes are marked as skipped and can be activated in hooks - see Testing non-2xx Responses with Swagger.Default responses are ignored by Dredd. Also, as of now, only
application/json
media type is supported inproduces
andconsumes
. Other media types are skipped.