Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6882
Closed
Open
Issue created Jul 07, 2020 by Administrator@rootContributor

[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.

Assignee
Assign to
Time tracking