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
  • #9928
Closed
Open
Issue created Jul 10, 2021 by Administrator@rootContributor4 of 5 checklist items completed4/5 checklist items

[BUG][Java] Reference to Consumer is ambiguous

Created by: Tomboyo

Bug Report Checklist

  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I generated a client for a specification with a component called Consumer. The generator produced a client with import statements for both java.util.function.Consumer and a ...model.Consumer. As a result, the code cannot compile because the reference to Consumer is ambiguous wherever the Consumer type is referenced:

// in file org/openapitools/client/api/DefaultApi.java

import org.openapitools.client.model.Consumer;
import java.util.function.Consumer; 
openapi-generator version

My project uses the latest release of the OpenAPI generator maven plugin:

<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.2.0</version>
OpenAPI declaration file content or url

Found in the example project here

Generation Details

The client is generated using the maven plugin. See the pom.xml

Steps to reproduce
git clone git@github.com:Tomboyo/openapigen-bug-exmaple.git
cd openapigen-bug-exmaple
./mvnw clean compile
Related issues/PRs

I could not find any.

Suggest a fix

One approach is to use fully-qualified names for all types that otherwise rely on generated import statements. For each generated method, we would qualify the return type and parameter types. (Or, similarly, we could fully-qualify only the types used in the verbatim template.)

Assignee
Assign to
Time tracking