silkapp / rest

Packages for defining APIs, running them, generating client code and documentation.
http://silkapp.github.io/rest
390 stars 52 forks source link

Accept headers are too lenient with errors #67

Open bergmark opened 10 years ago

bergmark commented 10 years ago

This is a continuation of #65 that won't make it into that PR.

If you have a resource declaring fileO . someO . jsonE . someE and request it with Accept: application/octet-stream you should get an error, the header should be Accept: application/octetstream,text/json or equivalent. Otherwise you may get a response in an unexpected format.

hesselink commented 10 years ago

Just to clarify: we currently check the accept headers against the provided output types always, but we only check them against the provided error types if an actual error occurs. This means you can have working code, until an error occurs. Then, instead of the error, you'll see that 'unsupported type'.

bergmark commented 10 years ago

I wasn't able to reproduce that part, it just responds with json when an error occurs even though it's not in the accept header

hesselink commented 10 years ago

Ah, that makes sense. It just picks something to be able to give the original error.

bergmark commented 10 years ago

Btw, this is probably low prio since generated clients in #65 will specify both output and error in the accept header if needed.