I migrated to latest springfox-swagger2
version 2.10.0
but looks like @EnableSwagger2
is deprecated.
What annotation should I use in order to enable Swagger into Spring Boot project? @EnableSwagger2WebMvc
?
@EnableSwagger2 was removed in swagger 2.10.x, but from 3.x.x it is there again.
@EnableSwagger2WebMvc is deprecated in 3.0.0+
Funny but true :)
Optionally you can use following dependency with Spring 5 MVC
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
and
see: https://github.com/springfox/springfox
@Configuration
@EnableSwagger2WebMvc
@Import({SpringDataRestConfiguration.class, BeanValidatorPluginsConfiguration.class})
public class ApplicationSwaggerConfig {
@Bean
public Docket schoolApi() {
return new Docket(DocumentationType.SWAGGER_2).
select().
apis(RequestHandlerSelectors.basePackage("com.example.SampleProject")).
paths(PathSelectors.any()).
build();
}
For the other case pertaining to spring security checks, you can make your securityconfiguration class to extend WebsecurityConfigurerAdapter and then you can implement below method -
@Override public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers( "/v2/api-docs", "/swagger-resources/**", "/configuration/ui","/configuration/security", "/swagger-ui.html");
}
This should help I guess
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With