I am upgrading spring boot version 2.x to 3.x with Java 17. The swagger OpenApi that is generated is unusable as follows:
<!-- HTML for static distribution bundle build --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Swagger UI</title> <link rel="stylesheet" type="text/css" href="./swagger-ui.css" /> <link rel="stylesheet" type="text/css" href="index.css" /> <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" /> <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" /> </head> <body> <div id="swagger-ui"></div> <script src="./swagger-ui-bundle.js" charset="UTF-8"> </script> <script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script> <script src="./swagger-initializer.js" charset="UTF-8"> </script> </body> </html>
my build.gradle has following:
‘org.springframework.boot:spring-boot-starter-webflux’,
‘org.springdoc:springdoc-openapi-starter-webflux-ui:2.5.0’,
Config class:
@Configuration
public class WebfluxConfig implements WebFluxConfigurer {
@Bean
public OpenAPI openApiConfig() {
return new OpenAPI().info(new Info()
.title("abc Service")
.description("abc")
.version("1.0")
.contact(new Contact()
.name("")
.email("x))
.license(new License()
.name("x")));
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/swagger-ui**").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META- INF/resources/webjars/");
}
Not sure what I am missing to get such swagger generated. I hope I can get some insight on this.
Thanks.
I tried using following gradle dependencies
'org.springdoc:springdoc-openapi-starter-webflux-api:2.5.0',
'org.springdoc:springdoc-openapi-core:1.1.49',
'io.swagger.core.v3:swagger-annotations:2.2.16',
removing addResourceHandlers. It didn’t help.
Kanchan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.