OpenAPITools / OpenAPITools/openapi-generator

[BUG] Dependency conflict (usage of swagger-annotations 1.6.8 and 2.2.4) leads to broken build

Open
#14,901 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Since openapi-generator 6.3.0 we're not able to build our project anymore. The reason therefore is that the generated classes from openapi-generator are generating methods with annotations like @Schema(name = "attr", requiredMode = Schema.RequiredMode.NOT_REQUIRED). The Schema.RequiredMode cannot be resolved properly because there are two versions of the same dependency in the classpath, both are used by the openapi-generator itself.

[INFO] +- org.openapitools:openapi-generator:jar:6.3.0:compile
[INFO] |  +- io.swagger.parser.v3:swagger-parser:jar:2.1.6:compile
[INFO] |  |  +- io.swagger.parser.v3:swagger-parser-v2-converter:jar:2.1.6:compile
[INFO] |  |  |  +- io.swagger:swagger-core:jar:1.6.8:compile
[INFO] |  |  |  |  +- io.swagger:swagger-models:jar:1.6.8:compile
[INFO] |  |  |  |  |  \- io.swagger:swagger-annotations:jar:1.6.8:compile
[INFO] |  |  \- io.swagger.parser.v3:swagger-parser-v3:jar:2.1.6:compile
[INFO] |  |     +- io.swagger.core.v3:swagger-core:jar:2.2.4:compile
[INFO] |  |     |  +- io.swagger.core.v3:swagger-annotations:jar:2.2.4:compile

The problem still persists in openapi-generator 6.4.0.

openapi-generator version
  • 6.3.0
  • 6.4.0
OpenAPI declaration file content or url

No specific API delcaration, since the problem is a dependency problem.

Generation Details

We use the Maven plugin for code generation from an OpenAPI spec. The corresponding config:

<configuration>
  <inputSpec>${project.basedir}/../myapp/openapi.yaml</inputSpec>
  <generatorName>spring</generatorName>
  <generateSupportingFiles>false</generateSupportingFiles>
  <modelPackage>com.company.mysoftware</modelPackage>
  <skipValidateSpec>true</skipValidateSpec>
  <configOptions>
    <sourceFolder>src/gen/java/main</sourceFolder>
    <reactive>true</reactive>
  </configOptions>
</configuration>
Steps to reproduce

Build the classes with Maven generator.

Related issues/PRs

None.

Suggest a fix

Use the same version of the dependency io.swagger.core.v3:swagger-annotations to prevent the classloader from dependency conflicts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Maven plugin configuration and the dependency tree shown in the issue, focusing on the swagger-parser and swagger-annotations versions used by openapi-generator. Reproduce the Maven build with the Spring generator; done means the generated classes compile without conflicting Swagger annotation versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.