有没有办法发送空的可选查询参数?

时间:2016-02-18 13:13:55

标签: apiblueprint apiary.io apiary

我正在编写API文档,并遇到了问题。

这是链接定义:

### Get hotels availability [GET /agent/v1/hotel/availability{?regions,hotels,from,to,limit,offset}]

参数:

+ Parameters 
    + regions (required,string,`399,189`)
    + hotels (optional, string, `1844`)
    + from (optional, string, `2016-03-12`)
    + to (optional, string, `2016-03-19`)
    + limit (optional, number, `1`)
    + offset (optional, number, `0`)

例如,当我尝试使用空hotels参数发送请求时,养蜂场使用1844而不是空。如果我尝试将其示例为空,则会hotels=hotels被发送。

有没有办法为可选参数发送空,或者根本不发送?

以下是截图链接: http://www.awesomescreenshot.com/image/1008356/09614be501945b0644fd84a06e311404

1 个答案:

答案 0 :(得分:5)

我不确定我是否正确理解你的问题。我试图重现你描述的行为。我在Apiary中创建了一个新的API项目,并编写了以下API Blueprint:

FORMAT: 1A

# Hotels API

# Group Hotels

## Hotels [/agent/v1/hotel/availability{?regions,hotels,from,to,limit,offset}]

+ Parameters 
    + regions (required,string,`399,189`)
    + hotels (optional, string, `1844`)
    + from (optional, string, `2016-03-12`)
    + to (optional, string, `2016-03-19`)
    + limit (optional, number, `1`)
    + offset (optional, number, `0`)

### Get hotels availability [GET]

+ Response 200 (application/json)

        {"hello":"world"}

然后我在生成的交互式文档中打开了控制台窗格,并尝试编辑URL参数:

editing URL parameters

顶部的网址正在更改。我向控制台发出了一些请求,并且Traffic Inspector页面似乎确认已发送了正确的参数:

enter image description here

我认为你必须改进你的问题并提供更多信息。此外,我认为这是一个特定的蜂房特定主题,而在support@apiary.io联系Apiary支持可能更有意义。如果您不喜欢电子邮件,那么还有一个互动聊天:

enter image description here

免责声明:在撰写答案时,我为Apiary工作。

相关问题