swapi icon indicating copy to clipboard operation
swapi copied to clipboard

Schema Changes Suggestions

Open caseysoftware opened this issue 9 years ago • 2 comments

Context:

  "films": [
      "http://swapi.co/api/films/1/",
      "http://swapi.co/api/films/2/",
      "http://swapi.co/api/films/3/"
  ],

Relevant section of the schema: https://github.com/phalt/swapi/blob/master/resources/schemas/people.json#L43

While listing out the films is a starting point, using HAL - http://stateless.co/hal_specification.html - would make this much more powerful. Check out the heading "Representing Multiple Links With The Same Relation" because structuring the JSON like this would allow more flexibility in displaying data without causing the client to make more requests.

_items: {
    "films": [{
            "name": "A New Hope",
            "href": "/films/1/"
    },{
            "name": "The Empire Strikes Back",
            "href": "/films/2/"
    }]
}

I'd also apply this to the species, vehicles, planets subresources but I wanted to give a single example.

caseysoftware avatar Feb 10 '15 18:02 caseysoftware

I'd love to do this, I wonder if there is a plugin for Django REST Framework that would make this super easy?

phalt avatar Feb 11 '15 10:02 phalt

Accepted into version 2

phalt avatar Feb 23 '15 13:02 phalt