JsonApiBundle icon indicating copy to clipboard operation
JsonApiBundle copied to clipboard

Serialize as json api on the base of the headers Content-Type and Accept

Open silverqx opened this issue 10 years ago • 4 comments

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.

silverqx avatar Jul 24 '15 21:07 silverqx

@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..

koemeet avatar Jul 26 '15 11:07 koemeet

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.

silverqx avatar Jul 27 '15 11:07 silverqx

@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.

koemeet avatar Aug 03 '15 15:08 koemeet

Ok

silverqx avatar Aug 03 '15 15:08 silverqx