Skip to content

Commit

Permalink
Merge a0b26b9 into 851b75d
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Jul 12, 2019
2 parents 851b75d + a0b26b9 commit aee014f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 22 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
4 changes: 2 additions & 2 deletions 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 All @@ -234,7 +234,7 @@ def _prepare_doc(operation, openapi_version):
continue
parameters = [
param for param in operation['parameters']
if not param['in'] == 'body'
if not param['in'] == 'json'
]
if parameters:
operation['parameters'] = parameters
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 aee014f

Please sign in to comment.