You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
one way is to use the flask after_request method and do these changes there. just check if 'errors' field is present in the response, if it is there. modify it. Consider the following example:
@app.after_request
def after_request(response):
if int(response.status_code) == 404:
response.set_data(dumps({'success': False, 'data': [],
'msg': 'Resource not found. Check Resouce URI again'}))
if int(response.status_code) >= 400:
response_data = loads(response.get_data())
if 'errors' in response_data:
response_data = {"error": "Please input the field"}
response.set_data(dumps(response_data))
response.headers.add('Content-Type', 'application/json')
return response
Is there a way to create a custom validation error for @api.expect(validation=True)?
The default validation error I get when I post something illegal is something like this:
I would like it to be customized to:
The text was updated successfully, but these errors were encountered: