Skip to content

Commit

Permalink
fixing openapi arrays filtering (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinisaos authored Dec 9, 2021
1 parent 8b66ff3 commit c6df628
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion piccolo_api/crud/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,16 @@ def _parse_params(self, params: QueryParams) -> t.Dict[str, t.Any]:
for i in itertools.groupby(params.multi_items(), lambda x: x[0])
}

array_columns = [
i._meta.name
for i in self.table._meta.columns
if i.value_type == list
]

output = {}

for key, value in params_map.items():
if key.endswith("[]"):
if key.endswith("[]") or key.rstrip("[]") in array_columns:
# Is either an array, or multiple values have been passed in
# for another field.
key = key.rstrip("[]")
Expand Down
2 changes: 1 addition & 1 deletion piccolo_api/fastapi/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def modify_signature(
]

for field_name, _field in model.__fields__.items():
type_ = _field.type_
type_ = _field.outer_type_
parameters.append(
Parameter(
name=field_name,
Expand Down

0 comments on commit c6df628

Please sign in to comment.