Parameterize a Data Structure in API-Blueprint

240 views Asked by At

I vaguely have the following document:

# Group Cats

## Get ALl The Cats [GET /api/v1/cats{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]

+ Parameters
    + page%5bsize%5d: 10 (number, optional) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d: 2 (number, optional) - Page number to fetchedfor the paginated response.

+ Request Success Reports (application/json)

+ Response 200 (application/json)
    + Attributes
        + data (array[Cat], required, fixed-type)
            + (Cat)
        + meta (Metadata, optional)
        + links (Links)

## Data Structures

### Links
+ self: `/api/v1/resources?page[number]=2&page[size]=10` (string, required)
+ first: `/api/v1/resources?page[number]=1&page[size]=10` (string, required)
+ last: `/api/v1/resources?page[number]=3&page[size]=10` (string, required)
+ prev: `/api/v1/resources?page[number]=1&page[size]=10` (string, required)
+ next: `/api/v1/resources?page[number]=3&page[size]=10` (string, optional)

I refactored the links out in its own data structures. All of that works well. What I want to do is make part of the urls in Links dynamic so that resources will be replace with whatever I pass in. So something like:

### Links (something)
+ self: `/api/v1/{something}?page[number]=2&page[size]=10` (string, required)
+ first: `/api/v1/{something}?page[number]=1&page[size]=10` (string, required)
+ last: `/api/v1/{something}?page[number]=3&page[size]=10` (string, required)
+ prev: `/api/v1/{something}?page[number]=1&page[size]=10` (string, required)
+ next: `/api/v1/{something}?page[number]=3&page[size]=10` (string, optional)

And then I could do something like this:

+ Response 200 (application/json)
    + Attributes
        + data (array[Cat], required, fixed-type)
            + (Cat)
        + meta (Metadata, optional)
        + links (Links `cats`)

replacing resources with cats.

0

There are 0 answers