mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 11:09:53 +00:00
Merge pull request #199 from p1c2u/fix/flask-error-handler-status-fix
Flask error handler status fix
This commit is contained in:
commit
d4e9fe4e60
2 changed files with 5 additions and 4 deletions
|
@ -22,10 +22,8 @@ class FlaskOpenAPIErrorsHandler(object):
|
||||||
data = {
|
data = {
|
||||||
'errors': data_errors,
|
'errors': data_errors,
|
||||||
}
|
}
|
||||||
status = max(
|
data_error_max = max(data_errors, key=lambda x: x['status'])
|
||||||
range(len(data_errors)),
|
status = data_error_max['status']
|
||||||
key=lambda idx: data_errors[idx]['status'],
|
|
||||||
)
|
|
||||||
return current_app.response_class(
|
return current_app.response_class(
|
||||||
dumps(data),
|
dumps(data),
|
||||||
status=status,
|
status=status,
|
||||||
|
|
|
@ -45,6 +45,7 @@ class TestFlaskOpenAPIView(object):
|
||||||
|
|
||||||
result = client.get('/browse/12/')
|
result = client.get('/browse/12/')
|
||||||
|
|
||||||
|
assert result.status_code == 415
|
||||||
assert result.json == {
|
assert result.json == {
|
||||||
'errors': [
|
'errors': [
|
||||||
{
|
{
|
||||||
|
@ -78,6 +79,7 @@ class TestFlaskOpenAPIView(object):
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
assert result.status_code == 500
|
||||||
assert result.json == expected_data
|
assert result.json == expected_data
|
||||||
|
|
||||||
def test_endpoint_error(self, client):
|
def test_endpoint_error(self, client):
|
||||||
|
@ -97,6 +99,7 @@ class TestFlaskOpenAPIView(object):
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
assert result.status_code == 400
|
||||||
assert result.json == expected_data
|
assert result.json == expected_data
|
||||||
|
|
||||||
def test_valid(self, client):
|
def test_valid(self, client):
|
||||||
|
|
Loading…
Reference in a new issue