AhmedBakran
AhmedBakran

Reputation: 135

OpenApi/Swagger with Spring boot integration issue

I am trying to integrate openApi with swagger in my spring boot application. The swagger UI loads, however it is not finding the swaggerjson file it needs to render the page.

I added the below dependencies:

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>1.5.12</version>
        </dependency>
        <!-- required for swagger-ui integration -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

Here is my Configuration class:

@Configuration
public class SwaggerConfig {
    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI().info(new Info()
                .title("Service API")
                .version("1")
                .description("Service"));
    }
}

Here is the error:

Ambiguous handler methods mapped for '/v3/api-docs': {public org.springframework.http.ResponseEntity springfox.documentation.oas.web.OpenApiControllerWebMvc.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest), public java.lang.String org.springdoc.webmvc.api.OpenApiWebMvcResource.openapiJson(javax.servlet.http.HttpServletRequest,java.lang.String,java.util.Locale) throws com.fasterxml.jackson.core.JsonProcessingException

Upvotes: 0

Views: 1551

Answers (1)

Hopey One
Hopey One

Reputation: 1816

I don't think you can use those dependencies together. They both do the same thing which means you are getting the 'ambiguous' error. This has some details on migrating from springfox.

Upvotes: 3

Related Questions