mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-22 03:00:10 +00:00
Flask error handler status fix
This commit is contained in:
parent
912f0afc7a
commit
15e9c28175
2 changed files with 5 additions and 4 deletions
|
@ -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,
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue