我们很难在API中描述任意大小的数组。使用API Blueprint和MSON格式进行Dredd测试。
Endpoint /spots应该返回一个“Spot”数组(它们是对象)。但我们不知道有多少。目前,我们只能让dredd验证数组的第一个点。这是我们的蓝图:
FORMAT: 1A
HOST: http://host.com/
# Our API
## Spots [/spots{?type}]
### List All Spots [GET]
+ Parameters
+ type (optional, string) - a filter on the spot type
+ Response 200 (application/json)
+ Attributes (array)
- (Spot)
# Data Structures
## Spot(object, fixed-type)
- name: `Spot name` (string)
- code : `SPOT1` (string, required)
- type: `spotType` (string)
## Spots(array, fixed-type)
- Spot如果我们在## Spots(array, fixed-type)中删除fixed-type,那么根本不会验证任何东西……
我们需要告诉他,Spot的所有元素都必须是Spot,但不限制有多少。
谢谢你的帮忙!
发布于 2017-08-09 21:16:29
你可以试试这样的东西。
## Spots (array[Spot], fixed-type)谢谢。
发布于 2017-11-21 23:35:51
这看起来像是Dredd中的一个bug:https://github.com/apiaryio/dredd/issues/177
https://stackoverflow.com/questions/45568397
复制相似问题