I have the following library referenced in my POM file
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.14</version>
</dependency>
In my code I have the following class defined
@EnableWebMvc
public class SwaggerMVC implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
I also have this class defined
@Configuration
public class SwaggerConfig {
@Bean
public GroupedOpenApi api() {
return GroupedOpenApi.builder()
.group("my-api")
.pathsToMatch("/**")
.pathsToExclude("/error.*")
.pathsToExclude("/actuator.*")
.pathsToExclude("/test.*")
.pathsToExclude("/swagger-ui.html")
.pathsToExclude("/swagger-ui/**")
.pathsToExclude("/v3/api-docs/**")
.pathsToExclude("/v3/api-docs.yaml")
.pathsToExclude("/api-docs/**")
.pathsToExclude("/api-docs.yaml")
.pathsToExclude("/swagger-ui-custom.html")
.pathsToExclude("/cloudfoundryapplication.*")
.build();
}
}
While experimenting with this and trying to get it to work, I added this to my application.properties
file
springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.path=/swagger-ui-custom.html
But, no matter what I try, I always get a 404 when I hit any of the following urls
http://localhost:8080/api-docs
http://localhost:8080/v3/api-docs
http://localhost:8080/api-docs.yaml
http://localhost:8080/v3/api-docs.yaml
http://localhost:8080/swagger-ui.html
What am I doing wrong?