I have spring (not spring boot) application with springfox3. Application swagger url is working fine.
I have to migrate from springfox to springdoc-openapi. I have implemented all migration steps mentioned in below url.
https://springdoc.org/migrating-from-springfox.html
My application swagger url is not working after migrating to springdoc-swagger. Swagger url - http://server:port/context/swagger-ui.html
Can anyone please help me what i am doing wrong. TIA
My changes are as below:
- Removed springfox dependency and added below in gradle:
compile ("org.springdoc:springdoc-openapi-ui:1.6.11")
- Commented single Docket and added below in application.properties file:
springdoc.packagesToScan=package
springdoc.pathsToMatch=/v1, /api/**
- Added below OpenAPI bean:
@Bean public OpenAPI springShopOpenAPI() {
return new OpenAPI()
.info(new Info().title("SpringShop API")
.description("Spring shop sample application")
.version("v0.0.1")
.license(new License().name("Apache 2.0").url("http://springdoc.org")))
.externalDocs(new ExternalDocumentation()
.description("SpringShop Wiki Documentation")
.url("https://springshop.wiki.github.org/docs"));
}
- I also had below config for springfox. I have done minor url change for opeanapi.
public class Config implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry theRegistry) {
theRegistry.
addResourceHandler("/swagger-ui/**")
//.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") --> springfox
.addResourceLocations("classpath:/META-INF/resources/") --> updated for springdoc
.resourceChain(false);
}
@Override
public void addViewControllers(ViewControllerRegistry theRegistry) {
theRegistry.addViewController("/swagger-ui/")
.setViewName("forward:" + "/swagger-ui/index.html");
}
Thanks