From a0b26b9f989ce4c59a1315f12fcae5368ab2561d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Sat, 13 Jul 2019 00:21:56 +0200 Subject: [PATCH] Remove __location_mapping__ and InvalidLocationError --- flask_rest_api/blueprint.py | 11 ----------- flask_rest_api/exceptions.py | 4 ---- tests/test_blueprint.py | 16 ---------------- 3 files changed, 31 deletions(-) diff --git a/flask_rest_api/blueprint.py b/flask_rest_api/blueprint.py index 7a729911..d66d116d 100644 --- a/flask_rest_api/blueprint.py +++ b/flask_rest_api/blueprint.py @@ -42,14 +42,12 @@ from flask import Blueprint as FlaskBlueprint from flask.views import MethodViewType -from apispec.ext.marshmallow.openapi import __location_map__ from .utils import deepupdate, load_info_from_docstring from .arguments import ArgumentsMixin from .response import ResponseMixin from .pagination import PaginationMixin from .etag import EtagMixin -from .exceptions import InvalidLocationError class Blueprint( @@ -243,15 +241,6 @@ def _prepare_doc(operation, openapi_version): else: del operation['parameters'] - if 'parameters' in operation: - for param in operation['parameters']: - try: - param['in'] = __location_map__[param['in']] - except KeyError as exc: - raise InvalidLocationError( - "{} is not a valid location".format(param['in']) - ) from exc - @staticmethod def doc(**kwargs): """Decorator adding description attributes to a view function diff --git a/flask_rest_api/exceptions.py b/flask_rest_api/exceptions.py index 56ee29e4..67d48093 100644 --- a/flask_rest_api/exceptions.py +++ b/flask_rest_api/exceptions.py @@ -11,10 +11,6 @@ class OpenAPIVersionNotSpecified(FlaskRestApiError): """OpenAPI version was not specified""" -class InvalidLocationError(FlaskRestApiError): - """Parameter location is not a valid location""" - - class CheckEtagNotCalledError(FlaskRestApiError): """ETag enabled on resource but check_etag not called""" diff --git a/tests/test_blueprint.py b/tests/test_blueprint.py index e3beba70..2ed9b7bc 100644 --- a/tests/test_blueprint.py +++ b/tests/test_blueprint.py @@ -10,7 +10,6 @@ from flask.views import MethodView from flask_rest_api import Api, Blueprint, Page -from flask_rest_api.exceptions import InvalidLocationError from .utils import build_ref @@ -62,21 +61,6 @@ def func(): assert 'parameters' not in get assert 'requestBody' in get - @pytest.mark.parametrize('openapi_version', ('2.0', '3.0.2')) - def test_blueprint_arguments_location_invalid( - self, app, schemas, openapi_version): - app.config['OPENAPI_VERSION'] = openapi_version - api = Api(app) - blp = Blueprint('test', __name__, url_prefix='/test') - - @blp.route('/') - @blp.arguments(schemas.DocSchema, location='invalid') - def func(): - """Dummy view func""" - - with pytest.raises(InvalidLocationError): - api.register_blueprint(blp) - @pytest.mark.parametrize('openapi_version', ('2.0', '3.0.2')) def test_blueprint_multiple_registrations(self, app, openapi_version): """Check blueprint can be registered multiple times