The point of the issue is that there is a check_headers decorator implemented in flask_rest_jsonapi.decorators:check_headers which never returns errors even if the request doesn't have correct header because these conditions will never be in True.
def check_headers(func):
...
if request.method in ('POST', 'PATCH'):
if 'Content-Type' in request.headers and\
'application/vnd.api+json' in request.headers['Content-Type'] and\
request.headers['Content-Type'] != 'application/vnd.api+json':
error = json.dumps(jsonapi_errors([{'source': '',
'detail': "Content-Type header must be application/vnd.api+json",
'title': 'Invalid request header',
'status': '415'}]), cls=JSONEncoder)
return make_response(error, 415, {'Content-Type': 'application/vnd.api+json'})
...
return func(*args, **kwargs)
return wrapper
Instead of the correct error message jsonapi returns:
Hello,
According to the documentation every
POST
andPATCH
methods should contain headers:otherwise the exception should be risen.
The point of the issue is that there is a
check_headers
decorator implemented inflask_rest_jsonapi.decorators:check_headers
which never returns errors even if the request doesn't have correct header because these conditions will never be inTrue
.Instead of the correct error message jsonapi returns:
@akira-dev could you please review the condition and fix the issue?
I've created Pull Request with possible solution.