Skip to content

Conversation

@winrid
Copy link
Contributor

@winrid winrid commented Nov 4, 2025

Fixes #22280
Fixes our sdk not compiling: https://github.com/fastcomments/fastcomments-rust

@dsteeley @jacob-pro

I had to add tests because existing tests did not cover this scenario.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@winrid
Copy link
Contributor Author

winrid commented Nov 6, 2025

Hey folks @frol @farcaller @richardwhiuk @paladinzh anyone willing to review this?

@wing328 wing328 added this to the 7.18.0 milestone Nov 8, 2025
@wing328 wing328 merged commit 2107686 into OpenAPITools:master Nov 8, 2025
17 checks passed
rajvesh pushed a commit to rajvesh/openapi-generator that referenced this pull request Dec 25, 2025
…n Failure (OpenAPITools#22281)

* [Rust Reqwest] Fixes Enums in Query Parameters via  Causing Compilation Failure

* regen
@thesn10
Copy link

thesn10 commented Jan 12, 2026

Unfortunately this PR introduces a pretty serious runtime bug that's probably breaking enum query parameters for everyone using the generated clients.

The problem is that serde_json::to_string() is designed for JSON serialization, so it wraps values in quotes. When you have something like:

pub enum SortOrder {
    #[serde(rename = "asc")]
    Ascending,
    #[serde(rename = "desc")]
    Descending,
}

You'd expect a URL like ?sortOrder=asc, but what you actually get is ?sortOrder=%22asc%22. Those %22 are URL-encoded quotes - the server literally receives "asc" as the value instead of just asc, which fails validation and breaks the API call.

This is because serde_json::to_string() produces JSON strings that must be quoted according to the spec. It's the right tool for JSON bodies, but completely wrong for query parameters which should be plain strings:

let sort = SortOrder::Ascending;
serde_json::to_string(&sort).unwrap()  // "\"asc\"" - wrong!
sort.to_string()                        // "asc" - correct

I get that the original compilation error needed fixing, but this change essentially trades a compile-time error for a runtime bug that silently breaks every API call using enum query parameters. Our production client is completely broken because of this.

This PR really needs to be reverted. The original type inference issue is real and needs a proper solution, but serde_json::to_string() is fundamentally incompatible with query parameter encoding.

Would it be possible to revert this and then we can figure out the right approach to fix the compilation issue without breaking query parameters?

@winrid @wing328

@winrid
Copy link
Contributor Author

winrid commented Jan 12, 2026

@thesn10 let me see if I can address this ASAP

@winrid
Copy link
Contributor Author

winrid commented Jan 12, 2026

I have a fix I am testing.

@winrid
Copy link
Contributor Author

winrid commented Jan 12, 2026

@thesn10 fix is in this PR: #22683

test to prevent this from regressing again: https://github.com/OpenAPITools/openapi-generator/pull/22683/files#diff-154b2d8c634a8e04936d2bb95522716bcf8502b6e226d035f48a87d88a4218c2R119

@winrid winrid deleted the rust-reqwest-error branch January 12, 2026 21:57
@thesn10
Copy link

thesn10 commented Jan 12, 2026

@winrid wow, thanks for fixing it that fast. I really appreciate your effort!

@winrid
Copy link
Contributor Author

winrid commented Jan 12, 2026

@thesn10 well I was very embarrassed! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [Rust] Enums in Query Parameters via $ref Cause Compilation Failure

3 participants