Skip to content

Make it possible to use swagger-annotations separately through springdoc-openapi dependency #2044

Closed

Description

@mpashka

Is your feature request related to a problem? Please describe.
We have multi modulw project. Let's say back, front and lib (back and front dependes on lib). And we have some class in lib that is useb by both back and front and is part of swagger public API. So we wanna put swagger annotations on that class. But we don't want all springdoc-openapi dependency in back module. And we don't want to use specific swagger-annotations depdendency to prevent collisions in case of springdoc upgrade.

So we would like to have single dependency for both springdoc-openapi-ui and swagger-annotations. Or at least to have two dependencies with the same version.

Describe the solution you'd like
Currently springdoc-openapi has dependency on io.swagger.core.v3:swagger-core. If you add io.swagger.core.v3:swagger-annotations dependency into springdoc-openapi pom then it will be possible to use springdoc-openapi as a bom to import both springdoc-openapi-ui and swagger-annotations. And then do it like that:

lib pom.xml:
<dependencyManagement>
    <dependencies>
            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi</artifactId>
                <version>_springdoc.version.here_</version>
            </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations</artifactId>
        </dependency>
</dependencies>

front pom.xml:
use lib as parent or import springdoc-openapi-bom other way
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
</dependency>

Describe alternatives you've considered

As an alternative it is possible to use the following dependency directly for springdoc-openapi 1.6.11:

<dependency>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-annotations</artifactId>
    <version>2.2.2</version>
</dependency>

Please note: on springdoc-openapi upgrade you have to remember to go to springdoc-openapi, find swagger-api version there and then to update swagger-annotations dependency.

Activity

  1. dominic-jones commented on Jan 20, 2023

    @dominic-jones

    This used to be the case. In v1.6.3 swagger-annotations was in the classpath. It appears to have been removed in v1.6.4 in #1424 - was this intentional?

  2. bnasslahsen commented on Feb 5, 2023

    @bnasslahsen
    Collaborator

    @dominic-jones and @mpashka,

    The swagger-core dependency includes swagger-annotations .
    You should not declare any swagger-xxx dependencies while using springdoc-openapi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions