Search code examples
apiblueprintapiary.io

API Blueprint resource definition not working correctly


This blueprint resource is giving me problems.

#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

As you can see its a simple get request, ie http://my-host.com/api/v1/inboundSMS?number=123&message=hello%20world&key=SECRETKEY

But, I am geting an error from apiary.io

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

As it's a GET request there is no message body so I don't know why its complaining about it being missing.


Solution

  • This error is because you have defined a "Request" with no headers or body. The Parameters section belongs outside of the "Request".

    You can remove the Request section and add the Parameters section in the outer level as follows to remove this error:

    ## 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
    

    You can also move the Parameters section to the resource instead of placing it in the action. So it will be shared across all actions inside the resource.

    ## 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