API Blueprint资源定义无法正常工作

时间:2014-12-17 10:30:33

标签: apiblueprint apiary.io

这个蓝图资源给了我一些问题。

#Group Data Ingress

## Inbound SMS [/api/v1/inboundSMS{?number,message,key}]

### Receive [GET]

+ Request

    + Parameters

        + number (int) ... The number the sms originated from
        + message (string) ... The message content
        + key (string) ... The inbound authentication key as defined in the application configuration

+ Response 200 (text/plain)

    + Body

            OK

正如您所见,它是一个简单的获取请求,即http://my-host.com/api/v1/inboundSMS?number=123&message=hello%20world&key=SECRETKEY

但是,我正在从apiary.io

发出错误
Line: 543 (The request line) Empty request message-body.
Line: 545 (The parameters line) Ignoring unrecognized block.

因为它是一个GET请求,所以没有消息正文,所以我不知道为什么抱怨它丢失了。

1 个答案:

答案 0 :(得分:1)

此错误是因为您已定义了"请求"没有标题或正文。参数部分属于"请求"。

您可以删除“请求”部分,并在外部级别添加“参数”部分,如下所示,以删除此错误:

## Inbound SMS [/api/v1/inboundSMS{?number,message,key}]

### Receive [GET]

+ Parameters

    + number (int) ... The number the sms originated from
    + message (string) ... The message content
    + key (string) ... The inbound authentication key as defined in the application configuration

 + Response 200 (text/plain)

    + Body

            OKAY

您还可以将“参数”部分移动到资源,而不是将其放在操作中。因此,它将在资源内的所有操作中共享。

## Inbound SMS [/api/v1/inboundSMS{?number,message,key}]

+ Parameters

    + number (int) ... The number the sms originated from
    + message (string) ... The message content
    + key (string) ... The inbound authentication key as defined in the application configuration

### Receive [GET]

 + Response 200 (text/plain)

    + Body

            OKAY