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
  • #4222
Closed
Open
Issue created Oct 22, 2019 by Administrator@rootContributor

[BUG][JAVA][RestTemplate] Specified Accept header values generates uncompilable code

Created by: crosbyb

Description
openapi-generator version

4.1.0, 4.1.3

OpenAPI declaration file content or url

See the attached swagger contract for the full example.

        "parameters": [
          {
            "in": "header",
            "name": "Accept",
            "schema": {
              "enum": [
                "application/vnd.geo+json",
                "text/csv"
              ]
            },
            "required": true
          }
        ],
Command line used for generation

swagger-client-config.json:

{
  "modelPackage": "sc.v0.client.model",
  "apiPackage": "svc.v0.client",
  "library": "resttemplate",
  "groupId": "api.clients",
  "artifactId": "svc-client",
  "artifactVersion": "0.0.1"
}

java -jar ./codegen.jar generate -c ./swagger-client-config.json -i ./swagger.json -g java -o client/

Steps to reproduce
mkdir client
java -jar ./codegen.jar generate -c ./swagger-client-config.json  -i ./swagger.json -g java -o client/
cd client/ && mvn install  -q -Dmaven.test.skip=true -Dmaven.javadoc.skip=true && cd ..

You'll see the following error when Maven tries to compile:

[ERROR] /Users/brad/tmp/openapi-accept/client/src/main/java/svc/v0/client/ServiceApi.java:[77,31] variable accept is already defined in method getAllThings(java.lang.String)

There is already a local variable in the method named accept, so adding the accept header as an argument to the method creates the conflict.

Assignee
Assign to
Time tracking