Skip to content

Commit

Permalink
Add array support for reqparser
Browse files Browse the repository at this point in the history
Add missing items for type array.
  • Loading branch information
splasky committed Jul 9, 2024
1 parent b38a7d9 commit 2bba8d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions flask_restx/reqparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from werkzeug import exceptions

from .errors import abort, SpecsError
from .fields import List
from .marshalling import marshal
from .model import Model
from ._http import HTTPStatus
Expand Down Expand Up @@ -167,6 +168,8 @@ def convert(self, value, op):

elif isinstance(self.type, Model) and isinstance(value, dict):
return marshal(value, self.type)
elif isinstance(self.type, List) and isinstance(value, list):
return value

# and check if we're expecting a filestorage and haven't overridden `type`
# (required because the below instantiation isn't valid for FileStorage)
Expand Down
6 changes: 5 additions & 1 deletion flask_restx/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ def build_request_body_parameters_schema(body_params):

properties = {}
for param in body_params:
properties[param["name"]] = {"type": param.get("type", "string")}
ptype = param.get("type", "string")
if ptype == "array":
properties[param["name"]] = {"type": "array", "items": param.get("type", "string")}
else:
properties[param["name"]] = {"type": param.get("type", "string")}

return {
"name": "payload",
Expand Down

0 comments on commit 2bba8d0

Please sign in to comment.