Skip to content

Commit

Permalink
Merge pull request #81 from Nobatek/rework_location_map
Browse files Browse the repository at this point in the history
Remove __location_map__
  • Loading branch information
lafrech authored Jul 15, 2019
2 parents cd40109 + af0979f commit 30d74a9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 21 deletions.
11 changes: 1 addition & 10 deletions flask_rest_api/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

from webargs import core
from webargs.flaskparser import FlaskParser
from apispec.ext.marshmallow.openapi import __location_map__

from .exceptions import InvalidLocationError


class ArgumentsMixin:
Expand Down Expand Up @@ -40,16 +37,10 @@ def arguments(
See :doc:`Arguments <arguments>`.
"""
try:
openapi_location = __location_map__[location]
except KeyError as exc:
raise InvalidLocationError(
"{} is not a valid location".format(location)) from exc

# At this stage, put schema instance in doc dictionary. Il will be
# replaced later on by $ref or json.
parameters = {
'in': openapi_location,
'in': location,
'required': required,
'schema': schema,
}
Expand Down
2 changes: 1 addition & 1 deletion flask_rest_api/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _prepare_doc(operation, openapi_version):
) = resp.pop(field)
if 'parameters' in operation:
for param in operation['parameters']:
if param['in'] == 'body':
if param['in'] == 'json':
request_body = {
x: param[x] for x in ('description', 'required')
if x in param
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
6 changes: 0 additions & 6 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,11 +61,6 @@ def func():
assert 'parameters' not in get
assert 'requestBody' in get

def test_blueprint_arguments_location_invalid(self, app, schemas):
blp = Blueprint('test', __name__, url_prefix='/test')
with pytest.raises(InvalidLocationError):
blp.arguments(schemas.DocSchema, location='invalid')

@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 30d74a9

Please sign in to comment.