apiaryio / api-blueprint

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

Hypermedia media types #291

Open zdne opened 8 years ago

zdne commented 8 years ago

Using the information from the Attributes section and the Action section

The API Blueprint parser should be able to render Hypermedia media types on behalf of the user.

For example given following (pseudo) blueprint:

# Resource Blog Post
- attributes
    - content (string)

## Action Retrieve Blog Post
- relation: list (self)
- response 200 (application/hal+json)
    - Attributes (Blog Post)
    - Affordances
        - list
        - edit

## Action Edit Blog Post 
- relation: edit

The response message payload body could be generated as:

{
    "_links": {
        "self": {"href": "..."},
        "edit": {"href": "..."},
    },
    "content": "..."
}

Note this feature can be dramatically improved by implementing the #288 and #290 where the - Affordances could refer to a state (and therefore its collection of affordances):

- Response 200 (application/hal+json)
    - Attributes (Blog Post)
    - Affordances (Archived) 
pksunkara commented 8 years ago

I love this part, Affordances could refer to a state. Simple but powerful.

akuckartz commented 8 years ago

First of all I would like to see support for application/ld+json.

jamesdixon commented 8 years ago

:+1:

This would be awesome! Just discovered Apiary and loving it so far, but would love to have the JSON API support.

Is there any progress on this? Would love to help out.

zdne commented 8 years ago

Hey @jamesdixon it is currently number 8 on the roadmap so no real progress just yet.

I guess next step is to start carving out the RFC for the specification. If you want to play with that and draft a syntax for capturing actions-affordances that would work together with the current actions that would be sweet

jamesdixon commented 8 years ago

Thanks, @zdne. I'll see what I can do as I start working with Apiary a bit more -- definitely need more time to familiarize myself with how things work. Cheers.