如何为资源指定多个GET操作

时间:2015-04-03 12:17:23

标签: apiblueprint

资源通常有多个get方法。通过查询参数获得单数或获得许多。这在蓝图中如何表现?我可以使用两个资源来完成它,但在我看来,这是不正确的,因为它是相同的资源。

与此问题相关如果在资源级别定义uri,如何将PUT添加到资源。

理想情况下,这就是我认为应该写的东西,但编辑不喜欢它。我在docs中找到了HTTP_ACTION和URI可以放在一起的内容,但是编辑器似乎想要在资源级别使用URI。

# Storefronts

## Read [GET /v1/storefronts{?query_params...}]

+ Parameter
    query_params ...

+ Request Matching Storefronts (application/json)
+ Response 200 (application/json)

## Read [GET /v1/storefronts/{id}]

+ Parameter
    + id (string) ... id for record to return
+ Request (application/json)
+ Response 200 (application/json)

## UPDATE [PUT /v1/storefronts/{id}]

+ Parameter
    + id (string) ... id for record to update
+ Request (application/json)
+ Response 200 (application/json)

1 个答案:

答案 0 :(得分:1)

从技术上讲,您有2个资源:一个代表具有身份的单个Storefront(通常支持GET,PUT,DELETE,PATCH),另一个代表Storefronts集合(通常支持GET,POST)。以下是您在API蓝图中的表示方式:

# Storefront [/v1/storefronts/{id}]

## Retreive a Single Storefront [GET]

## Update a Storefront [PUT]

## Delete a Storefront [DELETE]

# Storefronts Collection [/v1/storefronts]

## List Storefronts [GET]

## Create a New Storefront [POST]
相关问题