agrestio / agrest

Server-side Java REST Framework for easy access to data graphs from various backends
https://agrest.io
Apache License 2.0
80 stars 34 forks source link

SpringBoot 3 /SpringDoc dependency conflict #685

Closed Jorge-Fern closed 2 weeks ago

Jorge-Fern commented 2 weeks ago

After updating my project to Springboot 3 and the SpringDoc to version 2.6.0 (latest for springboot 3) I had many issues with swagger.

After some hours a lot a debugging and frustration, I found that the problem was caused by some conflicts in the dependencies.

I've done the following and everything is working again

    <!-- AgREST OpenAPI integration-->
    <!-- Exclude swagger dependencies to avoid conflict with SpringDoc-->
    <dependency>
        <groupId>io.agrest</groupId>
        <artifactId>agrest-jaxrs3-openapi</artifactId>
        <exclusions>
            <exclusion>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-jaxrs2-jakarta</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.fasterxml.jackson.module</groupId>
                <artifactId>jackson-module-jaxb-annotations</artifactId>
            </exclusion>
        </exclusions>
        <version>5.0.M19</version>
    </dependency>

    <!--  Explicitly include jaxrs2-jakarta (same version as swagger-core-jakarta used by SpringDoc) that was excluded fom AgREST-->
    <dependency>
        <groupId>io.swagger.core.v3</groupId>
        <artifactId>swagger-jaxrs2-jakarta</artifactId>
        <version>2.2.22</version>
    </dependency>

    <!-- SpringDoc -->
    <dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        <version>2.6.0</version>
    </dependency>

Maybe on the next release you could exclude the dependencies and update the version of "swagger-jaxrs2-jakarta", or just update the "Getting Started" docs with info for Springboot 3 to avoid problems for new users.

andrus commented 2 weeks ago

Hi, @Jorge-Fern , thanks for the feedback. Excluding Swagger (e.g. by making it a "provided" dependency) will make things harder for other users and there's no guarantee that there won't be an API conflict between the Swagger version that we use and the one a user has. So no matter what, someone will be affected.

So I guess in this case, we'll just upgrade everything to the latest versions and try to keep things current.

andrus commented 1 week ago

I just dug a bit deeper, and it turns out this issue is already fixed per #678 (upgrade to S. 2.2.2), which in fact provides some of the excludes in question. But I am going to bump Swagger version to the latest one anyways (2.2.23 per #687 ).

<dependency>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-jaxrs2-jakarta</artifactId>
    <version>${swagger.version}</version>
    <exclusions>
        <exclusion>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>