1package com.bhutanio.config;
2
3import org.springframework.context.annotation.Bean;
4import org.springframework.context.annotation.Configuration;
5import springfox.documentation.builders.ApiInfoBuilder;
6import springfox.documentation.builders.PathSelectors;
7import springfox.documentation.builders.RequestHandlerSelectors;
8import springfox.documentation.service.ApiInfo;
9import springfox.documentation.service.Contact;
10import springfox.documentation.spi.DocumentationType;
11import springfox.documentation.spring.web.plugins.Docket;
12import springfox.documentation.swagger2.annotations.EnableSwagger2;
13
14@Configuration
15@EnableSwagger2
16public class SwaggerConfiguration {
17 @Bean
18 public Docket bookHotelApi() {
19 return new Docket( DocumentationType.SWAGGER_2)
20 .select()
21 .apis( RequestHandlerSelectors.any())
22 .paths( PathSelectors.any())
23 .build()
24 .apiInfo(getApiInfo());
25 }
26
27 private ApiInfo getApiInfo() {
28 return new ApiInfoBuilder()
29 .title("Swagger By Bhutan IO")
30 .version("1.0")
31 .description("Some description here..")
32 .contact(new Contact("Bhutan IO", "http://www.bhutanio.com", "abcde@email.com"))
33 .license("Apache License Version 2.0")
34 .build();
35 }
36}Code language: JavaScript (javascript)
1@Override
2public void addResourceHandlers(ResourceHandlerRegistry registry) {
3 registry.addResourceHandler("swagger-ui.html")
4 .addResourceLocations("classpath:/META-INF/resources/");
5
6 registry.addResourceHandler("/webjars/**")
7 .addResourceLocations("classpath:/META-INF/resources/webjars/");
8}
1// Fixed by lowering the swagger version to 2.7.0
2
3@EnableWebSecurity
4@Configuration
5public class ResourceServerConfig extends WebSecurityConfigurerAdapter {
6//...//
7 public static final String[] AUTH_WHITELIST = {
8 "/swagger-ui.html/**", "/configuration/**", "/swagger-resources/**", "/v2/api-docs", "/webjars/**"
9 };
10//...//
11
12 @Override
13 public void configure(WebSecurity web) throws Exception {
14 web.ignoring().mvcMatchers(HttpMethod.OPTIONS, "/**");
15 web.ignoring().antMatchers(AUTH_WHITELIST);
16 }
17
18}