swapi icon indicating copy to clipboard operation
swapi copied to clipboard

#16 - Add meta field to the json response.

Open dgliwa opened this issue 10 years ago • 3 comments

Hey! This would be my first contribution. I was able to modify how the response is serialized to be formatted as follows:

{ "name": "Luke Skywalker", "height": "172", "mass": "77", "hair_color": "blond", "skin_color": "fair", "eye_color": "blue", "birth_year": "19BBY", "gender": "male", "homeworld": "http://localhost:8000/api/planets/1/", "films": [ "http://localhost:8000/api/films/1/", "http://localhost:8000/api/films/2/", "http://localhost:8000/api/films/3/", "http://localhost:8000/api/films/6/" ], "species": [], "vehicles": [ "http://localhost:8000/api/vehicles/14/", "http://localhost:8000/api/vehicles/30/" ], "starships": [ "http://localhost:8000/api/starships/12/", "http://localhost:8000/api/starships/22/" ], "url": "http://localhost:8000/api/people/1/", "meta": { "edited": "2014-12-20T21:17:56.891Z", "created": "2014-12-09T13:50:51.644Z" }

Please let me know if there is anything more/less I should do. Look forward to helping more if possible.

dgliwa avatar Feb 25 '16 00:02 dgliwa

@dgliwa Hey! Thank you so much for your first contribution :)

As this is changing how the API response format is, this could potentially break every integration that is looking for created and updated values in the responses. A general rule of thumb with API responses is "Never remove anything once it is live". Unfortunately I can't allow us to remove values, so could you please keep the created and updated values? We can add the Meta and use it for future, but we need to support legacy integrations.

phalt avatar Feb 25 '16 09:02 phalt

Ah that makes sense. I added them back in. Thanks for the quick response.

dgliwa avatar Feb 25 '16 13:02 dgliwa

@dgliwa :dancer: no problem!

phalt avatar Feb 25 '16 15:02 phalt