Skip to content

handle array-like and map-like query parameters - #1017

Merged
ahl merged 7 commits into
mainfrom
array-query-better
Dec 27, 2024
Merged

ahl merged 7 commits into
mainfrom
array-query-better

Conversation

@ahl

@ahl ahl commented Dec 23, 2024 •

Copy link
Copy Markdown
Collaborator

Closes #268, #409, #692, #724, #994.

Query parameters can be scalar values (string, numbers, etc.) today, but per the spec they may be arrays or objects. This PR addresses that gap by adding a proxy serde::Serializer (called progenitor_client::QueryParam) that adds proper handling of arrays. It also modifies code generation to properly handle all valid input types for query parameters. See #692 for a discussion of the alternatives.

Here's an example of the before and after for generated code:

before

            let mut query = Vec::with_capacity(1usize);
            if let Some(v) = &minseq {
                query.push(("minseq", v.to_string()));
            }
            #[allow(unused_mut)]
            let mut request = client
                .client
                .get(url)
                .header(
                    reqwest::header::ACCEPT,
                    reqwest::header::HeaderValue::from_static("application/json"),
                )
                .query(&query)
                .build()?;

after

            #[allow(unused_mut)]
            let mut request = client
                .client
                .get(url)
                .header(
                    reqwest::header::ACCEPT,
                    reqwest::header::HeaderValue::from_static("application/json"),
                )
                .query(&progenitor_client::QueryParam::new("minseq", &minseq))
                .build()?;

Note that due to behavior in reqwest described in #692, this does not address the existing gap regarding query parameters that are not style=form and explode=true (i.e. the default).

@ahl
ahl requested a review from augustuswm December 23, 2024 22:23
@ahl

ahl commented Dec 23, 2024

Copy link
Copy Markdown
Collaborator Author

@MichielHegemans my apologies for not reviewing #724, but I would greatly appreciate your review of this PR.

@ahl

ahl commented Dec 27, 2024

Copy link
Copy Markdown
Collaborator Author

Reviews still welcome, but I'm going to merge this

@ahl
ahl merged commit d836501 into main Dec 27, 2024
@ahl
ahl deleted the array-query-better branch December 27, 2024 04:06
github-merge-queue Bot pushed a commit to flox/flox that referenced this pull request May 30, 2025
Our version of progenitor was stuck on `0.6.0` since we specified `0.6`
in our Cargo.toml, and cargo/dependabot won't bump potentially breaking
changes, i.e. major version bumps or minor version bumps iff major == 0.

While this alos required bumping reqwest, at least statically, no
further breakages were discovered by this.

Notable changes:

- oxidecomputer/progenitor#1120
- oxidecomputer/progenitor#1017
- oxidecomputer/progenitor#1011
- oxidecomputer/progenitor#949
- oxidecomputer/typify#584
abus-sh pushed a commit to abus-sh/progenitor that referenced this pull request Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for array / object parameters

1 participant