Search code examples
apiblueprintapiary.ioapiary

defining json post parameters in apiary


I'm trying to create documentation for a project using json post requests.
Now for get requests I can easily define uri parameters.

However I want to do the same for json and other post requests.
I tried and wished it would work something like below, it displays the parameters in the example but it doesn't seem to be the way to do it...
Is there a way to do this properly?

## Post Inbound [/ws/3/inbound]
### Post Inbound [POST]


+ Request

        {
            "authentication":
                {
                    "location":"{location}",
                    "customer_id":{customer_id},
                    "context":"{context}"
                },
            "date":"",
            "reference":"",
            "details":
            [
                {
                    "article_code":"",
                    "qty_expected":
                },
                {
                    "article_code":"",
                    "qty_expected":
                }
            ]
        }

+ Parameters
    + location (required, string) - Target url of the wics server 
    + customer_id (required, int) - Customer ID
    + context (required, string) - Authentication context gotten from login
    + date (required, date) - Date format as yyyy-mm-dd
    + reference (required, string) - Reference
    + article_code (required, string) - Article code
    + qty_expected (required, int) - Quantity expected.

Solution

  • The Parameters keyword is to indicate URI parameters in API Blueprint, whereas the Attributes keyword is to indicate attributes such as those given during a request or response body.

    This would look something like the following for your request:

    ## Post Inbound [/ws/3/inbound]
    ### Post Inbound [POST]
    
    + Request (application/json)
    
        + Attributes
            + authentication (required, object)
                + location (required, string) - Target url of the wics server 
                + customer_id (required, number) - Customer ID
                + context (required, string) - Authentication context gotten from login
            + date: `2015-12-30` (required, string) - Date format as yyyy-mm-dd
            + reference (required, string) - Reference
            + details (required, array)
                + (object)
                    + article_code (required, string) - Article code
                    + qty_expected (required, number) - Quantity expected.
    
    + Response 204
    

    And rendered as such in Apiary:

    MSON expanded and rendered at Apiary

    The full specification for the MSON (the syntax for object notation used in API Blueprint) can be found at https://github.com/apiaryio/mson.