Skip to content

Instantly share code, notes, and snippets.

@worldspawn
Created December 16, 2013 08:24
Show Gist options
  • Save worldspawn/7983836 to your computer and use it in GitHub Desktop.
Save worldspawn/7983836 to your computer and use it in GitHub Desktop.
Bitta APIARY

Group Flavours

Flavour related resources of Mealstrom API

Flavour Collection [/flavours]

A collection of flavours

  • Model

    HAL + JSON representation of flavour resource

    • Body (application/hal+json)

      [{ "_links": { "self": { "href": "/flavours/10000000-0000-0000-0000-000000000000" } }, "id": "10000000-0000-0000-0000-000000000000", "label": "sweet" }]

Retrieve Flavours [GET]

  • Response 200 [Flavour Collection][]

Create Flavour [POST]

  • Request (application/json)

          {
              "label" : "sweet"
          }
    
  • Response 201

          {
              "_links": {
                  "self": { "href": "/flavours/10000000-0000-0000-0000-000000000000" }
              },
              "id": "10000000-0000-0000-0000-000000000000",
              "label": "sweet"
          }
    
  • Response 409

          {
              "message" : "A flavour with that label already exists"
          }
    

Flavour [/flavours/{id}]

  • Model

    • Body (application/hal+json)

        {
            "_links": {
                "self": { "href": "/flavours/10000000-0000-0000-0000-000000000000" }
            },
            "id": "10000000-0000-0000-0000-000000000000",
            "label": "sweet"
        }
      
@zdne
Copy link

zdne commented Dec 16, 2013

Content-Type definition is per model, response or request (payload).

Therefore instead of

+ Body (application/hal+json)

the whole model should be defined as of the application/hal+json type.

+ Model (application/hal+json)

Thus:

## Flavour Collection [/flavours]
A collection of `flavours`

+ Model (application/hal+json)

    HAL + JSON representation of flavour resource

    + Body

        [{
            "_links": {
                "self": { "href": "/flavours/10000000-0000-0000-0000-000000000000" }
            },
            "id": "10000000-0000-0000-0000-000000000000",
            "label": "sweet"
        }]

This will fix the problem. However it would be nice if the parser would report this. I have created an issue for this at apiaryio/snowcrash#65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment