OpenAPITools / OpenAPITools/openapi-generator

[BUG] Duplicate access token headers in Rust Client

Open
#14,149 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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.

https://github.com/OpenAPITools/openapi-generator/blob/12fd115af3d72ff5cef59dacc6fab3f9d4c47b7e/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache#L218

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.