apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.64k stars 2.14k forks source link

Resources affording other resources actions (linking) #288

Open zdne opened 8 years ago

zdne commented 8 years ago

Given this blueprint (currently valid syntax):

# Author [/author/{id}]
- Parameters
    - id (number) - Id of the author
- Attributes
    - email (string) - Email of the author

## Retrieve Author [GET]
- Relation: self
- Response 200 (application/json)   
    - Attributes (Author)

I want to be able express that another resource affords the "Retrieve Author" action without the need to duplicate the "Retrieve Author".

For example like this:

# Blog Post [/blogpost/{id}]
- Parameters
    - id (number) - Id of the Blog Post
- Attributes
    - content (string) - Content of the Blog Post

## Retrieve [GET]
- Relation: self
- Response 200 (application/json)   
    - Attributes (Blog Post)

## Action Retrieve Gist Author 
- Relation: author (Author[self])

This enables linking of the resources and hence HATEOAS description.

To be addressed in draft APIB RFC

pksunkara commented 8 years ago

Can you please update the last part of the second example? It's not exactly clear. Is it an action?

zdne commented 8 years ago

@pksunkara that is just a sketch of my idea. Yes, it is introducing the Action keyword (so you do not have to specify a method)