1

我依稀有以下文件:

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

我在自己的数据结构中重构了链接。所有这些都运作良好。我想要做的是Links动态地制作部分网址,以便resources用我传入的任何内容替换。所以像:

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

然后我可以做这样的事情:

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

替换resourcescats.

4

0 回答 0