A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/swagger-api/swagger-codegen/issues/8359 below:

[JAVA][RESTEasy] ApiClient sets header-key as header-value · Issue #8359 · swagger-api/swagger-codegen · GitHub

Description

I created a Java client with the swagger-codegen-maven-plugin and I am setting custom headers over the ApiClient. But when looking at the request, I see that the headers are set but use the header key as value parameter.

Swagger-codegen version

swagger-codegen-maven-plugin: 2.3.1
with:

<configuration>
  <inputSpec>...</inputSpec>
  <language>java</language>
  <output>...</output>
  ...
  <configOptions>
    <library>resteasy</library>
    <java8>true</java8>
      ...
  <configOptions>
<configuration>
Example

When performing a request with the configured client.

ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.addDefaultHeader("headerKey1", "headerValue1");
defaultClient.addDefaultHeader("headerKey2", "headerValue2");
..some request.

The reuqest has the following headers:

whereas it should be :

Problem file

ApiClient.java:

public <T> T invokeAPI(String path,  .... ) {
  ...
  for (Entry<String, String> defaultHeaderEnrty: defaultHeaderMap.entrySet()) {
    if (!headerParams.containsKey(defaultHeaderEnrty.getKey())) {

      ########################
      String value = defaultHeaderEnrty.getKey();  <=== This should use the value.
      ########################

      if (value != null) {
        invocationBuilder = invocationBuilder.header(defaultHeaderEnrty.getKey(), value);
      }
    }
  }
  ...
}
Pull Request

#8360


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4