Home > Enterprise >  springdoc-openapi-ui:1.6.7 and higher does not display API UI
springdoc-openapi-ui:1.6.7 and higher does not display API UI

Time:11-14

I have this Spring project:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.5</version>
    <relativePath/>
</parent>

and this dependency:

    <dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-ui</artifactId>
        <version>1.6.6</version>
    </dependency>

Everything works, API UI is displayed.

However, when I upgrade springdoc-openapi-ui to version 1.6.7 and higher, I get this exception when I visit the API UI:

HttpStatus: 500 INTERNAL_SERVER_ERROR: {}.
org.springframework.web.util.NestedServletException: handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: io/swagger/v3/oas/annotations/media/PatternProperties

This is displayed when you visit the API UI page: enter image description here

Update:

Here's related mvn dependency:tree output:

[INFO] |   - org.springframework.kafka:spring-kafka:jar:2.8.10:compile
[INFO] |  |   - org.springframework:spring-context:jar:5.3.23:compile
[INFO] |  |   - org.springframework:spring-messaging:jar:5.3.23:compile
[INFO] |  |   - org.springframework:spring-tx:jar:5.3.23:compile
[INFO] |  |  \- org.apache.kafka:kafka-clients:jar:3.1.2:compile
[INFO] |  |      - com.github.luben:zstd-jni:jar:1.5.0-4:runtime
[INFO] |  |      - org.lz4:lz4-java:jar:1.8.0:runtime
[INFO] |  |     \- org.xerial.snappy:snappy-java:jar:1.1.8.4:runtime
[INFO] |  \- io.confluent:kafka-avro-serializer:jar:7.2.1:compile
[INFO] |      - org.apache.avro:avro:jar:1.11.0:compile
[INFO] |      - io.confluent:kafka-schema-serializer:jar:7.2.1:compile
[INFO] |      - io.confluent:kafka-schema-registry-client:jar:7.2.1:compile
[INFO] |     |  \- io.swagger.core.v3:swagger-annotations:jar:2.1.10:compile

What has changed and what needs to be modified?

CodePudding user response:

The problem was caused by the older version of package io.swagger.core.v3:swagger-annotations:2.1.10, which was added to the project by a transitive dependency (latest version is 2.2.6 at the moment).

There are 2 possible solutions:

Force the use of the latest version of the swagger-annotations package.

or

Exclude the swagger-annotations package dependency:

<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-avro-serializer</artifactId>
<version>7.2.2</version>
<exclusions>
    <exclusion>
        <groupId>io.swagger.codegen.v3</groupId>
        <artifactId>swagger-annotations</artifactId>
    </exclusion>
</exclusions>
</dependency>

swagger-annotations then enters the project as a transitive dependency of the springdoc-openapi-ui package.

  • Related