miLibris / flask-rest-jsonapi

Flask extension to build REST APIs around JSONAPI 1.0 specification.

Home Page:http://flask-rest-jsonapi.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Non-JSON MIME types

multimeric opened this issue · comments

I realise this has been discussed briefly at #13. However, we don't yet have a good solution.

The problem is this: I want my API to input and output data in both CSV and JSON format. When dealing with JSON I of course want to use the JSON API spec, and flask-rest-jsonapi should deal with that perfectly. The problem is, I don't want to duplicate all my code to also support CSV. I want the URLs, the schemas, and the models to be exactly the same as the JSON API. The only difference is that I want a hook that runs before loading and after dumping JSON data, when the Accept/Content Type header is csv, in order to convert to/from JSON. Is this possible?