Bug description When integrating Swagger with a Spring AI project, the application fails to start (throws NoSuchMethodError and similar errors) if the springdoc-openapi version is different from 2.8.5. It seems that Spring AI is not fully compatible with other versions of springdoc-openapi.

Environment Spring AI version: 1.0.1 Java version: 21 Spring Boot version: 3.5.3 Swagger/OpenAPI dependency: springdoc-openapi

Steps to reproduce - Create a Spring AI project. - Add springdoc-openapi dependency with version different from 2.8.5 (e.g., 2.5.0 or latest). - Run the application. - Observe runtime errors related to Swagger integration (e.g., NoSuchMethodError in io.swagger.v3.oas.annotations.Parameter).

Expected behavior Swagger should work with any compatible springdoc-openapi version, not just 2.8.5.

Image

Comment From: dafriz

io.swagger.core.v3:swagger-annotations-jakarta:jar:2.2.25 comes in as a nested dependency of org.springframework.ai:spring-ai-model.

You can exclude it so that the newer version from swagger is used. I.e If you are using the OpenAI model starter, import it like this

<dependency>
  <groupId>org.springframework.ai</groupId>
  <artifactId>spring-ai-starter-model-openai</artifactId>
  <exclusions>
    <exclusion>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-annotations-jakarta</artifactId>
    </exclusion>
  </exclusions>
</dependency>

We can keep updating the version used by Spring AI, but it may fall behind. This is why I updated to 2.2.25, so that an earlier version of springdoc would work in https://github.com/spring-projects/spring-ai/pull/2024

Comment From: oussemas-inspark

@dafriz excluding the swagger-annoations-jakarata dependency doesnt solve the issue

<dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-starter-model-openai</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.swagger.core.v3</groupId>
                    <artifactId>swagger-annotations-jakarta</artifactId>
                </exclusion>
            </exclusions>
 </dependency>

Image

Comment From: dafriz

Looks like it's using an older version of swagger-annotations-jakarta still. Might be conflicting with another dependency. Can use ./mvnw dependency:tree to track down further exclusions.

Note I've also raised a PR to update Spring AI to use 2.2.30 which should fix this issue in a futur release.

Comment From: oussemas-inspark

You are corrcet, i had to exclude it also from spring-ai-starter-model-chat-memory-repository-jdbc spring-ai-rag and all spring ai related arrtificats