swagger-api / swagger-api/swagger-codegen-generators

[Bug]: Duplicated default headers in ApiClient for Java RestTemplate

Open
#1,389 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Description

It should be possible to set default header for each HTTP request. Currently generated ApiClient class for resttemplate library does not allow that and creates duplicates.

The same issue was fixed 8 years ago in version 2 of the swagger-codegen: https://github.com/swagger-api/swagger-codegen/pull/6981 however the fix was never backported to the version 3.

For example, after executing:
apiClient.addDefaultHeader("TestHeader", "foo");
apiClient.addDefaultHeader("TestHeader", "bar");
Only TestHeader with value bar should be added to the request.

Version

all

Language / Generator Affected

Java - resttemplate library

Related Issues / Repos

https://github.com/swagger-api/swagger-codegen/issues/6976

Checklist

  • I have searched the existing issues to avoid duplicates.
  • I have included a minimal reproducible spec or configuration.
  • I have clearly described the steps to reproduce the issue.
  • I have specified which generator or template is affected.

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 locating the generated ApiClient for the Java resttemplate library and compare its default-header behavior with the referenced swagger-codegen pull request #6981. Reproduce the two addDefaultHeader calls from the issue and verify that the generated request contains only the latest value for TestHeader.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.