swagger-api / swagger-api/swagger-codegen

Java "resteasy" ApiClient not adding default HTTP headers correctly

Open
#7,758 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

In the ApiClient.java file around line 592 the following code is responsible for adding the default http headers to the request.

for (Entry<String, String> defaultHeaderEnrty: defaultHeaderMap.entrySet()) {
  if (!headerParams.containsKey(defaultHeaderEnrty.getKey())) {
    String value = defaultHeaderEnrty.getKey();
    if (value != null) {
      invocationBuilder = invocationBuilder.header(defaultHeaderEnrty.getKey(), value);
    }
  }
}

The line "String value = defaultHeaderEnrty.getKey();" is wrong and should have been "String value = defaultHeaderEnrty.getValue();"

Swagger-codegen version

2.3.1

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

Open ApiClient.java around line 592 and inspect how defaultHeaderMap entries are used when building the request. Confirm the header value comes from each entry's value rather than its key, then verify that generated resteasy clients send configured default HTTP headers correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.