jmcarp / flask-apispec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect handling of responses? (None -> 200)

dmzio opened this issue · comments

In flask typical DELETE method may look like this

    def delete(self, obj_id):
            DAL.delete(obj_id)

as Flask mentions in dispatch_request(), "return value not have to be a response object. In order to convert the return value to a proper response object, call make_response()."

So, we're returning None and expecting 204 status code.

Flask-apispec sets in wrapper.py status_code=200 for such (None) reponses, without any ways to override this behavior and set proper 204 status.

Your docs shows use of return make_response('', 204) in every DELETE endpoint, but this looks like unnecessary boilerplate, just to overcome the issue above.

Can be an another way to achieve proper status code?


Note
Before the version 0.8.7 there was a possibility to handle this in APISPEC_FORMAT_RESPONSE, but now that doesn't work.