Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [JAVA] [Client] Using different Content Types results in Accept Header [Ljava.lang.String;@XXXXXXXX #18590

Open
manuelnagler opened this issue May 7, 2024 · 4 comments

Comments

@manuelnagler
Copy link

Description

Regression in 7.5.0: Using different Content Types results in Accept Header generated as [Ljava.lang.String;@xxxxxxxx

openapi-generator version

Broken since 7.5.0.
7.4.0 works as expected

OpenAPI declaration file content or url
openapi: 3.0.2
info:
  title: Demo
  version: "1"
paths:
  /demo:
    post:
      requestBody:
        content:
          application/text:
            schema:
              type: string
      responses:
        '200':
          description: demo
          content:
            application/pdf:
              schema:
                type: string
                format: byte
        '500':
          description: demo
          content:
            application/text:
              schema:
                type: string
Steps to reproduce

Generate e.g. a feign client from the spec.

Result:

@RequestLine("POST /demo")
@Headers({
    "Content-Type: application/text",
    "Accept: [Ljava.lang.String;@7d0332e1",
})
byte[] demoPost(String body);

Expected:

@RequestLine("POST /demo")
@Headers({
    "Content-Type: application/text",
    "Accept: application/pdf,application/text",
})
byte[] demoPost(String body);

The Accept Header is not serialized properly into the generated interface.

@wing328
Copy link
Member

wing328 commented May 7, 2024

looks like it's related to #18092

@larsenf-els can you please take a look when you've time?

@yasstec
Copy link

yasstec commented May 16, 2024

Yeah, facing same issue

@larsenf-els
Copy link
Contributor

@manuelnagler @wing328 @yasstec:
I will have a look.

@larsenf-els
Copy link
Contributor

larsenf-els commented May 17, 2024

@manuelnagler @yasstec

I cannot reproduce the issue you are facing. I may need some additional information, and it could be due to me calling the wrong Feign client generator?

I created a small project here at GitHub that uses Gradle to call the OpenAPI Generator 7.5.0 on the provided OpenAPI specification file used for producing the error:

https://github.com/larsenf-els/feign-openapi-generator-test

Hava a look at the build.gradle.kts file. It generates this file:
/feign-openapi-generator-test/build/generated/src/main/java/org/openapitools/client/api/DefaultApi.java

package com.example.api;

import com.example.invoker.ApiClient;
import com.example.invoker.EncodingUtils;
import com.example.model.ApiResponse;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import feign.*;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-05-17T10:57:18.694179+02:00[Europe/Copenhagen]", comments = "Generator version: 7.5.0")
public interface DefaultApi extends ApiClient.Api {


  /**
   * 
   * 
   * @param body  (optional)
   * @return byte[]
   */
  @RequestLine("POST /demo")
  @Headers({
    "Content-Type: application/text",
    "Accept: application/pdf,application/text",
  })
  byte[] demoPost(String body);

  /**
   * 
   * Similar to <code>demoPost</code> but it also returns the http response headers .
   * 
   * @param body  (optional)
   * @return A ApiResponse that wraps the response boyd and the http headers.
   */
  @RequestLine("POST /demo")
  @Headers({
    "Content-Type: application/text",
    "Accept: application/pdf,application/text",
  })
  ApiResponse<byte[]> demoPostWithHttpInfo(String body);


}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants