Search code examples
spring-bootswagger-uispringfoxspringfox-boot-starter

Swagger UI is rendered incorrectly after upgrading Springfox from 2.x to 3.0.0


I am working on a Spring Boot 2.2.x application. I have upgraded the Springfox version from 2.5.x to 3.0.0 by following these instructions: migration from 2.x to 3.0.0

Swagger/Springfox configuration:

private ApiInfo apiInfo() {
     return new ApiInfo(“Api”,”1.0”,swaggerdoc(), new Contact(“Name”,”Url”,”email”),””,””,Collections.emptyList());

}

private String swaggerDoc() {
     return “<Html and css as string>”
}

In Swagger UI generated by Springfox 2.5.x I can see that the style tags in CSS are working as expected. But with Springfox 3.0.0, I can see the page is not loading the CSS files and thus displaying most of the HTML as text.

enter image description here

Any thoughts on why CSS is not coming into the picture?


Solution

  • Looks like there are no css and jquery libraries included in the latest version (springfox 3.0.0). We need to customize the /index.html call for localhost:8080/swagger-ui/ in order to add additinonal styling and to include jquery.