首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >任意大小的Dredd / apiary / MSON数组

任意大小的Dredd / apiary / MSON数组
EN

Stack Overflow用户
提问于 2017-08-08 20:29:01
回答 2查看 202关注 0票数 2

我们很难在API中描述任意大小的数组。使用API Blueprint和MSON格式进行Dredd测试。

Endpoint /spots应该返回一个“Spot”数组(它们是对象)。但我们不知道有多少。目前,我们只能让dredd验证数组的第一个点。这是我们的蓝图:

代码语言:javascript
复制
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,但不限制有多少。

谢谢你的帮忙!

EN

回答 2

Stack Overflow用户

发布于 2017-08-09 21:16:29

你可以试试这样的东西。

代码语言:javascript
复制
## Spots (array[Spot], fixed-type)

谢谢。

票数 1
EN

Stack Overflow用户

发布于 2017-11-21 23:35:51

这看起来像是Dredd中的一个bug:https://github.com/apiaryio/dredd/issues/177

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45568397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档