package org.example.seed.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.http.MediaType;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.time.LocalDate;

/**
 * Created by PINA on 27/06/2017.
 */
@Configuration
@EnableSwagger2
@Profile("local")
public class SwaggerConfig extends WebMvcConfigurerAdapter {

  @Override
  public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON);
  }

  @Override
  public void addResourceHandlers(final ResourceHandlerRegistry registry) {

    registry.addResourceHandler("swagger-ui.html")
      .addResourceLocations("classpath:/META-INF/resources/");

    registry.addResourceHandler("/webjars/**")
      .addResourceLocations("classpath:/META-INF/resources/webjars/");
  }

  @Bean
  public Docket configuration() {
    return new Docket(DocumentationType.SWAGGER_2)
      .select()
      .apis(RequestHandlerSelectors
        .basePackage("org.example.seed.rest"))
      .paths(PathSelectors.any())
      .build()
      .directModelSubstitute(LocalDate.class, String.class)
      .genericModelSubstitutes(DeferredResult.class);
  }
}

@@ -930,16 +930,115 @@
 17.%0A */%0A
+%0A// TODO: See how to add a new adapter instead of WebMvcConfigurerAdapter with Spring Fox Swagger%0A%0A
 @Configu
@@ -1078,16 +1078,49 @@
 local%22)%0A
+@SuppressWarnings(%22deprecation%22)%0A
 public c
@@ -1177,32 +1177,32 @@
  %7B%0A%0A  @Override%0A
-
   public void co
@@ -1272,24 +1272,25 @@
 nfigurer) %7B%0A
+%0A
     configur
@@ -1714,16 +1714,17 @@
 ion() %7B%0A
+%0A
     retu

add TODO just to comment