swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.39k stars 2.19k forks source link

module xxx reads package io.swagger.v3.oas.annotations from both io.swagger.v3.oas.annotations and io.swagger.v3.oas.models #4167

Closed lWoHvYe closed 2 years ago

lWoHvYe commented 2 years ago

Hi. My Project is based on Java 9 with named module. When I upgrade to swagger 2.2.0, I catched module xxx reads package io.swagger.v3.oas.annotations from both io.swagger.v3.oas.annotations and io.swagger.v3.oas.models when I compile it . I think it may cased by split package. Is there any way to solve it. Thinks.

Here is the demo of this

rherrick commented 2 years ago

I ran into the same thing with io.swagger.core.v3:swagger-models:2.2.0. The following classes are in that library:

There's no way that I can determine to work around this other than downgrading to an earlier version.

vab2048 commented 2 years ago

I think this is occurring because split packages are forbidden and are now present in the project:

Work will need to be done to make sure that there are no split packages.... otherwise the library will not work with Java modules.

leolcao commented 2 years ago

For now, downgrading to 2.1.12 version can solve this bug. BTW, I find this bug by using springdoc-openapi-ui 1.6.8 (1.6.7+, starting supporting the 2.2.0 version), so I downgrade it to 1.6.6 version, then works.

ALekseiMokhov commented 2 years ago

io.swagger.v3.core.util.AnnotationsUtils.class throws java.lang.NoSuchMethodError: 'io.swagger.v3.oas.annotations.media.Schema$AdditionalPropertiesValue io.swagger.v3.oas.annotations.media.Schema.additionalProperties()' Version springdoc-openapi-ui 1.6.8. And as was said above, it could be fixed by downgrading to 1.6.6

rherrick commented 2 years ago

I submitted the PR #4195 a couple days ago. Since then I've built and run my project with Springdoc 1.6.9 and Swagger 3 v2.2.1-SNAPSHOT (built and deployed on my private dev server and repo) and Swagger works properly.

frantuma commented 2 years ago

Thanks all for reporting and working on this! It has been indeed a mistake in package use for the introduce model specific annotations. Thanks @rherrick for the PR, we would however keep swagger-models package not dependent on other packages (specifically annotations), we would go therefore for package renaming as implemented in #4200. This solution has its drawback in "slightly" breaking backwards compatibility with 2.2.0, but being "minor" and limited to the newly introduced annotations, we would think this is still the best way to go.

Any comment welcome, would otherwise merge #4200 and cut a release in the next days

frantuma commented 2 years ago

fixed in #4200