WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion flask_restplus/reqparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,13 @@ def parse(self, request, bundle_errors=False):
def __schema__(self):
if self.location == 'cookie':
return
if isinstance(self.location, six.string_types):
location = self.location
else:
location = self.location[-1]
param = {
'name': self.name,
'in': LOCATIONS.get(self.location, 'query')
'in': LOCATIONS.get(location, 'query')
}
_handle_arg_type(self, param)
if self.required:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_reqparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,24 @@ def test_files_and_body_location(self):

assert cm.value.msg == "Can't use formData and body at the same time"

def test_location_json_or_values(self):
parser = RequestParser()
parser.add_argument('in_json_or_values', type=str, location=['json', 'values'])
assert parser.__schema__ == [{
'name': 'in_json_or_values',
'type': 'string',
'in': 'query',
}]

def test_location_values_or_json(self):
parser = RequestParser()
parser.add_argument('in_values_or_json', type=str, location=['values', 'json'])
assert parser.__schema__ == [{
'name': 'in_values_or_json',
'type': 'string',
'in': 'body',
}]

def test_models(self):
todo_fields = Model('Todo', {
'task': fields.String(required=True, description='The task details')
Expand Down