我隐约有以下文件:
# 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
中的URL成为动态的一部分,以便将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`)
用resources
代替cats
。