OpenAPITools / OpenAPITools/openapi-generator
[BUG] Duplicate access token headers in Rust Client
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- [ x ] Have you validated the input using an OpenAPI validator (example)?
- [ ] Have you tested with the latest master to confirm the issue still exists?
- [ x ] Have you searched for related issues/PRs?
- [ x ] What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using the Rust Client generator, the template is causing the authentication failures using the oauth token.
The errors are caused by duplicate headers added to the requests:
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/12163
https://github.com/OpenAPITools/openapi-generator/issues/11318
Suggest a fix
I haven't figured out how to properly build with custom templates, but my suspicion is that the template code is the issue, with both the bearer and oauth options point to the same header call.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache around line 218, then generate a Rust client with an OAuth access token and compare the emitted request headers. Done means the generated request adds the access-token authentication header only once; related issues 12163 and 11318 may provide context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100