Skip to content

Commit

Permalink
Remove the validation of input location (#397)
Browse files Browse the repository at this point in the history
Co-authored-by: Grey Li <withlihui@gmail.com>
fixes #259
  • Loading branch information
mmdbalkhi committed Jan 17, 2023
1 parent 5d55c84 commit fdf7eda
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Expand Up @@ -2,6 +2,10 @@

Released: -

- Remove the validation of input locations ([issue #259][issue_259]).

[issue_259]: https://github.com/apiflask/apiflask/issues/259


## Version 1.2.1

Expand Down
9 changes: 0 additions & 9 deletions src/apiflask/scaffold.py
Expand Up @@ -25,9 +25,6 @@
from .views import MethodView

BODY_LOCATIONS = ['json', 'files', 'form', 'form_and_files', 'json_or_form']
SUPPORTED_LOCATIONS = BODY_LOCATIONS + [
'query', 'headers', 'cookies', 'querystring', 'path', 'view_args'
]


class FlaskParser(BaseFlaskParser):
Expand Down Expand Up @@ -299,12 +296,6 @@ def decorator(f):
'body location (one of "json", "form", "files", "form_and_files", '
'and "json_or_form").'
)
if location not in SUPPORTED_LOCATIONS:
raise ValueError(
'Unknown input location. The supported locations are: "json", "files",'
' "form", "cookies", "headers", "query" (same as "querystring"), "path"'
f' (same as "view_args") and "form_and_files". Got {location!r} instead.'
)
if location == 'json':
_annotate(f, body=schema, body_example=example, body_examples=examples)
elif location == 'form':
Expand Down
9 changes: 0 additions & 9 deletions tests/test_decorator_input.py
Expand Up @@ -10,7 +10,6 @@
from .schemas import Foo
from .schemas import Form
from .schemas import FormAndFiles
from .schemas import Query
from apiflask.fields import String
from apiflask.views import MethodView

Expand Down Expand Up @@ -235,14 +234,6 @@ def foo(query):
pass


def test_bad_input_location(app):
with pytest.raises(ValueError):
@app.route('/foo')
@app.input(Query, location='bad')
def foo(query):
pass


def test_input_with_dict_schema(app, client):
dict_schema = {
'name': String(required=True)
Expand Down

0 comments on commit fdf7eda

Please sign in to comment.