Skip to content

Commit

Permalink
Remove __location_mapping__ and InvalidLocationError
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Jul 12, 2019
1 parent 1f39ee8 commit a0b26b9
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 31 deletions.
11 changes: 0 additions & 11 deletions flask_rest_api/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions flask_rest_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down
16 changes: 0 additions & 16 deletions tests/test_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a0b26b9

Please sign in to comment.