Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork16.7k
Comments
Add JSONIFY_MIMETYPE configuration variable#1728
Conversation
| def test_jsonify_mimetype(): | ||
| app = flask.Flask(__name__) | ||
| app.config.update({"JSONIFY_MIMETYPE": 'application/vnd.api+json'}) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
jeffwidman commentedApr 8, 2016
LGTM |
untitaker commentedApr 8, 2016
LGTM, but the changelog entry is now for the wrong version. |
Allow jsonify responses' mimetype to be configured
sloria commentedApr 8, 2016
OK, I've rebased with the latest |
davidism commentedJul 12, 2022
I'm currently implementing a new "JSON provider" interface for customizing how an app handles JSON. As part of that, I'm deprecating the However, reviewing this I'm not clear that setting the mimetype unconditionally is correct. The JSON API mimetype seems to be specifically for responses related to its own metadata and introspection, not to the actual API responses. It makes much more sense to me to set the content type for the specific responses that need it: response=jsonify(data)response.mimetype="application/vnd.api+json"returnresponse Am I missing something here or can I remove the configuration entirely? Note that it would still be possible to change the default using a custom provider: classVndProvider(DefaultJSONProvider):defresponse(self,*args,**kwargs):response=super().response(*args,**kwargs)response.mimetype="application/vnd.cool-api.v1+json"returnresponseapp.json=VndProvider(app) |
It is often useful to be able to return a vendor media type for JSON responses. For example,JSON API requires that all responses have the
Content-Type: applications/vnd.api+jsonheader.