4

My springboot webflux application was working and I was able to access swagger ui on url:

http://localhost:8080/webjars/swagger-ui/index.html.

Note: For me Tomcat initialized with port(s): 8080 (http)

POM contains the below dependency

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

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

My main java class is as below

@OpenAPIDefinition(info = @Info(title = "APIs", version = "1.0", description = "Documentation OHM APIs v1.0"))
public class ReactiveApplication {

  public static void main(String[] args) {
    SpringApplication.run(ReactiveApplication.class, args);
  }

}

All of a sudden I am not able to access webflux swagger anymore on the same url which was working earlier.

Getting below error:

2023-01-05 13:49:36,906 WARN  [http-nio-8080-exec-9] o.s.web.servlet.PageNotFound.noHandlerFound: No mapping for GET /webjars/swagger-ui/index.html
2023-01-05 13:49:36,907 WARN  [http-nio-8080-exec-9] o.s.web.servlet.PageNotFound.handleNoHandlerFoundException: No handler found for GET /webjars/swagger-ui/index.html
2023-01-05 13:49:36,907 WARN  [http-nio-8080-exec-9] o.s.w.s.m.s.DefaultHandlerExceptionResolver.logException: Resolved [org.springframework.web.servlet.NoHandlerFoundException: No handler found for GET /webjars/swagger-ui/index.html]

Can anyone help me understand what to do now. By default on which path webflux swagger can be accessed?

I also tried the below url to access swagger but it did not worked.

http://localhost:8080/swagger-ui.html

http://localhost:8080/swagger-ui

Abdullah Imran
  • 259
  • 3
  • 13
  • 1
    The default swagger path is still not working however on changing the default swagger-ui path ,it started working again. Added in application.yml springdoc: swagger-ui: path: /v1/swagger-ui.html Able to access it now on http://localhost:8080/v1/swagger-ui.html which redirects to http://localhost:8080/v1/webjars/swagger-ui/index.html . Can anyone help me know why the default path i.e. http://localhost:8080/webjars/swagger-ui/index.html is still not working. – Abdullah Imran Jan 13 '23 at 03:48

1 Answers1

4

I got the solution. The issue was with the combination of dependency for springboot starter and swagger that works well.

For swagger integration with springboot

If we are working with SpringBoot version less than 3 than springdoc 1.6.14/1.6.13 works well. So we need to add below two dependency for swagger

https://springdoc.org/

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-webflux-ui</artifactId>
            <version>1.6.14</version>
        </dependency>
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-webflux-core</artifactId>
            <version>1.6.14</version>
        </dependency>

If we are working with SpringBoot version 3 or more than 3 than springdoc-openapi V2 works well. For swagger we need to add below one dependency

https://springdoc.org/v2/

<dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
      <version>2.0.2</version>
   </dependency>
Abdullah Imran
  • 259
  • 3
  • 13