Skip to content

Commit

Permalink
Merge 08612b8 into d5295d3
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Sep 16, 2019
2 parents d5295d3 + 08612b8 commit 2ad009e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
3 changes: 1 addition & 2 deletions flask_rest_api/error_handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Exception handler"""

from werkzeug.exceptions import HTTPException
from flask import jsonify


class ErrorHandlerMixin:
Expand Down Expand Up @@ -62,4 +61,4 @@ def handle_http_exception(self, error):
if 'headers' in data:
headers = data['headers']

return jsonify(payload), error.code, headers
return payload, error.code, headers
13 changes: 6 additions & 7 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytest

from flask import jsonify
from flask.views import MethodView
from werkzeug.routing import BaseConverter
import marshmallow as ma
Expand Down Expand Up @@ -34,12 +33,12 @@ class CustomConverter(BaseConverter):
if view_type == 'function':
@blp.route('/<custom_str:val>')
def test_func(val):
return jsonify(val)
pass
else:
@blp.route('/<custom_str:val>')
class TestMethod(MethodView):
def get(self, val):
return jsonify(val)
pass

api.register_blueprint(blp)
spec = api.spec.to_dict()
Expand Down Expand Up @@ -75,11 +74,11 @@ class CustomConverter_2(BaseConverter):

@blp.route('/1/<custom_str_1:val>')
def test_func_1(val):
return jsonify(val)
pass

@blp.route('/2/<custom_str_2:val>')
def test_func_2(val):
return jsonify(val)
pass

api.register_blueprint(blp)
spec = api.spec.to_dict()
Expand Down Expand Up @@ -195,7 +194,7 @@ def test_api_register_blueprint_options(self, app):

@blp.route('/')
def test_func():
return jsonify('OK')
return {'response': 'OK'}

api.register_blueprint(blp, url_prefix='/test2')

Expand All @@ -208,7 +207,7 @@ def test_func():
assert response.status_code == 404
response = client.get('/test2/')
assert response.status_code == 200
assert response.json == 'OK'
assert response.json == {'response': 'OK'}

@pytest.mark.parametrize('openapi_version', ['2.0', '3.0.2'])
@pytest.mark.parametrize('base_path', [None, '/', '/v1'])
Expand Down
10 changes: 3 additions & 7 deletions tests/test_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import marshmallow as ma

from flask import jsonify
from flask.views import MethodView

from flask_rest_api import Api, Blueprint, Page
Expand Down Expand Up @@ -243,10 +242,7 @@ def test_blueprint_arguments_multiple(self, app, schemas, openapi_version):
@blp.arguments(schemas.DocSchema)
@blp.arguments(schemas.QueryArgsSchema, location='query')
def func(document, query_args):
return jsonify({
'document': document,
'query_args': query_args,
})
return {'document': document, 'query_args': query_args}

api.register_blueprint(blp)
spec = api.spec.to_dict()
Expand Down Expand Up @@ -563,7 +559,7 @@ def test_blueprint_doc_function(self, app):
@blp.route('/', methods=('PUT', 'PATCH', ))
@blp.doc(summary='Dummy func', description='Do dummy stuff')
def view_func():
return jsonify({'Value': 'OK'})
return {'Value': 'OK'}

api.register_blueprint(blp)
spec = api.spec.to_dict()
Expand Down Expand Up @@ -943,7 +939,7 @@ def test_blueprint_response_response_object(self, app, schemas):
# Schema is ignored when response object is returned
@blp.response(schemas.DocSchema, code=200)
def func_response():
return jsonify({}), 201, {'X-header': 'test'}
return {}, 201, {'X-header': 'test'}

api.register_blueprint(blp)

Expand Down

0 comments on commit 2ad009e

Please sign in to comment.