Skip to content

Handle expand query params as comma separated list #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ LICENSE.md
.github/workflows/semgrep.yml

# Files that avoid breaking changes due to renames.
src/merge/resources/accounting/types/currency_enum.py
src/merge/resources/accounting/types/currency_enum.py

# File that encodes enum query params as comma separated lists by default
src/merge/core/query_encoder.py
3 changes: 3 additions & 0 deletions src/merge/core/query_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = N


def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]:
# Special-case for 'expand' parameter: join lists into a comma-separated string
if query_key == "expand" and isinstance(query_value, list):
return [(query_key, ",".join(str(x) for x in query_value))]
if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict):
if isinstance(query_value, pydantic.BaseModel):
obj_dict = query_value.dict(by_alias=True)
Expand Down