Swagger UI shows no APIs

时间:2017-08-14 07:09:57

标签: spring-boot swagger swagger-ui

I have a Spring Boot Gradle project. I added Swagger but I see no APIs in the UI: Swagger-ui screen shot

These are the lines in the build.gradle:

compile("io.springfox:springfox-swagger2:2.7.0")
compile("io.springfox:springfox-swagger-ui:2.7.0")

This is the Main:

@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan(basePackages = {"com.aaa"})
public class Starter {    
  public static void main(String[] args) {
    SpringApplication.run(Starter.class, args);
  }
}

This is the config:

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {    
        @Bean
        public Docket api() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.aaa.controller"))
                    .paths(PathSelectors.ant("/api/*"))
                    .build();
        }    
}

There is no @EnableWebMvc.
I do have some more config classes per profiles but they are only annotated with @Configuration, @Profile and @PropertySource.
I also have a CORS filter - but even when I removed it, swagger did not work.

What did I do wrong?

0 个答案:

没有答案