0
votes

I am having springfox swagger2 where http://localhost:8080/context/swagger-ui.html works fine. Now I have modified all the changes to make it open-api runnable.
Using : Migrating from springfox swagger2 to springdoc openapi

Now I can open my service definition json by using group name like below:

http://localhost:8080/context-path/v3/api-docs/groupName

but unable to open swagger-ui.html like what i had earlier with springfox 2.0

Can you help me,how to open & what should be the url?
when I type http://localhost:8080/context/swagger-ui.html, it's creating new route like below & not opening anything,404 error.

http://localhost:8080/context/swagger-ui/index.html?configUrl=/context/v3/api-docs/swagger-config

Please note ,I have added swagger-ui.html in my project as it's added already for swagger 2.0

public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
      .addResourceLocations("classpath:/META-INF/resources/");

    registry.addResourceHandler("/webjars/**")
      .addResourceLocations("classpath:/META-INF/resources/webjars/");

Please help to get swagger home screen so that I can test rest services

1
pls help.......Skabdus

1 Answers

2
votes

The issue is that Swagger-UI is exposed at http://localhost:8080/swagger-ui.html

If you want that Swagger-UI should be under the context root, update the following property in application.properties file or it's equivalent.

springdoc.swagger-ui.path=/your-context-path/swagger-ui.html

The list of properties can be found here