package {{configPackage}};

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
{{#useOptional}}
import java.util.Optional;
{{/useOptional}}

{{>generatedAnnotation}}
@Configuration
public class SwaggerDocumentationConfig {

    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
            .title("{{appName}}")
            .description("{{{appDescription}}}")
            .license("{{licenseInfo}}")
            .licenseUrl("{{licenseUrl}}")
            .termsOfServiceUrl("{{infoUrl}}")
            .version("{{appVersion}}")
            .contact(new Contact("","", "{{infoEmail}}"))
            .build();
    }

    @Bean
    public Docket customImplementation(){
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                    .apis(RequestHandlerSelectors.basePackage("{{apiPackage}}"))
                    .build()
                {{#java8}}
                .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
                .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
                {{/java8}}
                {{#joda}}
                .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
                .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
                {{/joda}}
                {{#threetenbp}}
                .directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class)
                .directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class)
                {{/threetenbp}}
                {{#useOptional}}
                .genericModelSubstitutes(Optional.class)
                {{/useOptional}}
                .apiInfo(apiInfo());
    }

}
