[BUG][JAVA] Java-Jersey2 generator creates "Accept:null" header
Created by: 40rn05lyv
Description
I use Jersey2 as generator for my REST, including DELETE operations that don't "accept" any body. As a result, I see that the generated code executes HTTP requests with header "Accept:null" that is not a valid header (because of "null" string).
openapi-generator version
I use openapi-generator-maven-plugin 4.2.3, but from what I see in source code this bug should be reproducible in the master too.
OpenAPI declaration file content or url
paths:
/v2/something/{name}:
delete:
tags:
- Repository
summary: Delete something
operationId: something_delete
parameters:
- name: paramone
in: path
required: true
schema:
type: string
responses:
"204":
description: delete success or nothing to delete
"401":
description: not authenticated / invalid credentials
"403":
description: not authorized, the current user does not have the "repository"
privilege
"500":
description: internal server error
Command line used for generation
pom.xml config:
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.2.3</version>
...
<generatorName>java</generatorName>
<configOptions>
<java8>true</java8>
<library>jersey2</library>
</configOptions>
...
Steps to reproduce
See description, it's quite obvious.
Related issues/PRs
Not found
Suggest a fix
In file openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache
change line from
Invocation.Builder invocationBuilder = target.request().accept(accept);
to
Invocation.Builder invocationBuilder = accept != null ? target.request().accept(accept) : target.request();
Also, need to check other generator for this problem.