You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Multiple argument locations can be specified by passing a list to location:
parser.add_argument('text', location=['headers', 'values'])
When multiple locations are specified, the arguments from all locations specified are combined into a single MultiDict. The last location listed takes precedence in the result set."
However, trying to use a list for the location parameter yields an exception when the "schema" method is executed.
Due to the last location "json", the Swagger file should show 'in "body"' for that argument.
Actual behavior:
Exception occuring since a list is unexpected.
2019-10-04 17:44:51,729 ERROR api: Unable to render schema
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/flask_restplus/api.py", line 483, in __schema__
self._schema = Swagger(self).as_dict()
File "/usr/local/lib/python3.5/dist-packages/flask_restplus/swagger.py", line 177, in as_dict
paths[extract_path(url)] = self.serialize_resource(ns, resource, url, kwargs)
File "/usr/local/lib/python3.5/dist-packages/flask_restplus/swagger.py", line 336, in serialize_resource
doc = self.extract_resource_doc(resource, url)
File "/usr/local/lib/python3.5/dist-packages/flask_restplus/swagger.py", line 255, in extract_resource_doc
method_params = self.expected_params(method_doc)
File "/usr/local/lib/python3.5/dist-packages/flask_restplus/swagger.py", line 291, in expected_params
parser_params = OrderedDict((p['name'], p) for p in expect.__schema__)
File "/usr/local/lib/python3.5/dist-packages/flask_restplus/reqparse.py", line 405, in __schema__
param = arg.__schema__
File "/usr/local/lib/python3.5/dist-packages/flask_restplus/reqparse.py", line 269, in __schema__
'in': LOCATIONS.get(self.location, 'query')
TypeError: unhashable type: 'list'
@property
def __schema__(self):
if self.location == 'cookie':
return
if isinstance(self.location, six.string_types):
location = self.location
else:
location = self.location[-1] # last location listed takes precedence in the result set, thus use this here
param = {
'name': self.name,
'in': LOCATIONS.get(location, 'query')
}
The text was updated successfully, but these errors were encountered:
According to section "Multiple Locations" in the documentation (https://flask-restplus.readthedocs.io/en/stable/parsing.html) the following holds:
"Multiple argument locations can be specified by passing a list to location:
parser.add_argument('text', location=['headers', 'values'])
When multiple locations are specified, the arguments from all locations specified are combined into a single MultiDict. The last location listed takes precedence in the result set."
However, trying to use a list for the location parameter yields an exception when the "schema" method is executed.
Example:
myargs = reqparse.RequestParser()
myargs.add_argument('label', type=str, required=True, help='Test', location=['values', 'json'])
...
@ns.expect(myargs)
...
Expected behavior:
Due to the last location "json", the Swagger file should show 'in "body"' for that argument.
Actual behavior:
Exception occuring since a list is unexpected.
Resolution:
Current lines 265ff in reqparse.py:
New lines 265ff in reqparse.py:
The text was updated successfully, but these errors were encountered: