Swagger-ui.html not showing api list

14,511

I fixed the problem. The problem is browser cache. I just cleared all the cache, and then I'm able to get the swagger-ui.html with all api list.

Share:
14,511
Sundar G
Author by

Sundar G

Looking for learning.......

Updated on June 06, 2022

Comments

  • Sundar G
    Sundar G almost 2 years

    I'm using spring boot + swagger 2 for documenting all the REST API .I'm able to list all the api of a controller when i have the below project structure.

    enter image description here

    If i move the swaggerconfig.java to the config package then i'm not able to list all api of a controller.i'm getting enter image description here

    This is my SwaggerConfig.java

    @Configuration
    @EnableAutoConfiguration
    //@ComponentScan(basePackages="com.javainuse.swaggertest")
    @EnableSwagger2
    public class SwaggerConfig {
    
        @Bean
        public Docket postsApi() {
            return new Docket(DocumentationType.SWAGGER_2).groupName("public-api")
                    .apiInfo(apiInfo()).select().paths(postPaths()).build();
        }
    
        private Predicate<String> postPaths() {
            return or(regex("/api/posts.*"), regex("/api/javainuse.*"));
        }
    
        private ApiInfo apiInfo() {
            return new ApiInfoBuilder().title("JavaInUse API")
                    .description("JavaInUse API reference for developers")
                    .termsOfServiceUrl("http://javainuse.com")
                    .contact("[email protected]").license("JavaInUse License")
                    .licenseUrl("[email protected]").version("1.0").build();
        }
    
    }
    

    What i'm doing wrong