JsonApiBundle
JsonApiBundle copied to clipboard
Serialize as json api on the base of the headers Content-Type and Accept
Hi, I discovered another solution, how could be resolved this problem and it's based on headers. I think that it's much cleaner solution.
The headers Content-Type and Accept will be checked, if contains application/vnd.api+json value, as is described here http://jsonapi.org/format/#content-negotiation, if yes so the entities will be serialized by json api serializer.
And I don't know if it's implemented now, but in this step would be good to implement 415 Unsupported Media Type and 406 Not Acceptable responses on the base of this rules http://jsonapi.org/format/#content-negotiation-servers. Or to create new ticket.
@szachara I was thinking about this too, but I am not sure if we want this as the default behaviour. It is indeed a very clean way to do it. But it could resolve in some weird behaviour (if we leave it under the json format) which can confuse people a lot. Need to think more about this..
Ok and what about 415 and 406 responses, they are acceptable, do they?
I need to think about content negotiation too, if there is something more we can do or implement. Of course everything it's OK for now.
@szachara They are indeed, the JSON-API spec is pretty big and in the future I want to make if fully compatible. I will flag this issue for 1.0.
Ok