Skip to content

Commit 2bba8d0

Browse files
committed
Add array support for reqparser
Add missing items for type array.
1 parent b38a7d9 commit 2bba8d0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

flask_restx/reqparse.py

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from werkzeug import exceptions
1212

1313
from .errors import abort, SpecsError
14+
from .fields import List
1415
from .marshalling import marshal
1516
from .model import Model
1617
from ._http import HTTPStatus
@@ -167,6 +168,8 @@ def convert(self, value, op):
167168

168169
elif isinstance(self.type, Model) and isinstance(value, dict):
169170
return marshal(value, self.type)
171+
elif isinstance(self.type, List) and isinstance(value, list):
172+
return value
170173

171174
# and check if we're expecting a filestorage and haven't overridden `type`
172175
# (required because the below instantiation isn't valid for FileStorage)

flask_restx/swagger.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ def build_request_body_parameters_schema(body_params):
214214

215215
properties = {}
216216
for param in body_params:
217-
properties[param["name"]] = {"type": param.get("type", "string")}
217+
ptype = param.get("type", "string")
218+
if ptype == "array":
219+
properties[param["name"]] = {"type": "array", "items": param.get("type", "string")}
220+
else:
221+
properties[param["name"]] = {"type": param.get("type", "string")}
218222

219223
return {
220224
"name": "payload",

0 commit comments

Comments
 (0)