Flask error handler status fix

This commit is contained in:
Artur Maciag 2020-02-18 11:51:42 +00:00
parent 912f0afc7a
commit 15e9c28175
2 changed files with 5 additions and 4 deletions

View file

@ -22,10 +22,8 @@ class FlaskOpenAPIErrorsHandler(object):
data = {
'errors': data_errors,
}
status = max(
range(len(data_errors)),
key=lambda idx: data_errors[idx]['status'],
)
data_error_max = max(data_errors, key=lambda x: x['status'])
status = data_error_max['status']
return current_app.response_class(
dumps(data),
status=status,

View file

@ -45,6 +45,7 @@ class TestFlaskOpenAPIView(object):
result = client.get('/browse/12/')
assert result.status_code == 415
assert result.json == {
'errors': [
{
@ -78,6 +79,7 @@ class TestFlaskOpenAPIView(object):
}
]
}
assert result.status_code == 500
assert result.json == expected_data
def test_endpoint_error(self, client):
@ -97,6 +99,7 @@ class TestFlaskOpenAPIView(object):
}
]
}
assert result.status_code == 400
assert result.json == expected_data
def test_valid(self, client):