Justin
Justin

Reputation: 299

How can you specify multiple GET actions for a Resource

Resources usually have multiple get methods. Get a singular or get many by query params. How is this represented in blueprint? I can do it using two resources, but that in my opinion is not correct as its the same resource.

Related to this question How does one add PUT to the resource given the uri is defined at the resource level.

Ideally this is how i think things should be written but the editor doesn't like it. I have found in docs where the HTTP_ACTION and URI can be put together, but the editor seems to want the URI at the resource level.

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

Upvotes: 1

Views: 514

Answers (1)

Todd Menier
Todd Menier

Reputation: 39379

Technically you have 2 resources: one representing a single Storefront with an identity (typically supporting GET, PUT, DELETE, PATCH) and one representing a collection of Storefronts (typically supporting GET, POST). Here's how you would represent this in API Blueprint:

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

Upvotes: 1

Related Questions