carrot / restful-api-spec

Carrots spec/process for building RESTful APIs
MIT License
14 stars 0 forks source link

Handle `content` in base interface when nothing is returned #1

Open BrandonRomano opened 8 years ago

BrandonRomano commented 8 years ago

In the event that we have a bulk fetch endpoint, let's say for example /v1/model, and there is nothing returned because there are simply no models. We should specify how to handle this.

We could return a 204 error as http status code spec suggests, but I actually argue against this for our spec, and simply have it return an empty array with a 200 (this is how we have traditionally handled this).

There might actually be useful information we would want to pass in the body (perhaps an error-detail), and most http clients respect the 204 request and don't pass along any body.

BrandonRomano commented 8 years ago

@tmilewski would like to hear your thoughts on this. I'm pretty confident you're in agreement, but just want to verify.

2020Deception commented 8 years ago

Do you think there will be relevant error details for a fetch that returns empty data? I think if a 204 is returned, the client side should deal with it accordingly bc most likely the reason why the data is empty should be straight forward enough where the client side shouldn't need further instructions. I'm just scratching the API surface but i would love read everyone's thoughts on everything. I've seen API's that handle it both ways and never really understood why to go one way or the other except for personal preference.