phalt / swapi

*NOT MAINTAINED - NO GUARENTEE TO BE UP*
https://phalt.github.io/pokeapi-and-swapi-going-forward/
BSD 3-Clause "New" or "Revised" License
892 stars 505 forks source link

Schema Changes Suggestions #9

Open caseysoftware opened 9 years ago

caseysoftware commented 9 years ago

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.

phalt commented 9 years ago

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

phalt commented 9 years ago

Accepted into version 2