package it.enea.cruise.config;

import java.util.ArrayList;


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

import it.enea.scp.idp.sdk.model.UserDto;
import it.enea.cruise.data.ElectricMeterReading;
import it.enea.cruise.model.user.Community;
import it.enea.cruise.model.user.Device;
import it.enea.cruise.model.user.Role;
import it.enea.cruise.model.user.User;
import springfox.documentation.builders.PathSelectors;
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;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@ComponentScan("it.enea.cruise")
public class SpringFoxConfig {         
	
    @Bean
    public Docket api() { 
        return new Docket(DocumentationType.SWAGGER_2)  
          .select()                                  
          .apis(RequestHandlerSelectors.any())              
          .paths(PathSelectors.any())
          .build()
          .apiInfo(apiInfo())
          .useDefaultResponseMessages(false)
          .ignoredParameterTypes(UserDto.class)
         .ignoredParameterTypes(Community.class)
          .ignoredParameterTypes(Device.class)
          .ignoredParameterTypes(ElectricMeterReading.class)
          .ignoredParameterTypes(Role.class)
          .ignoredParameterTypes(User.class)
          ;
    }
   
    private ApiInfo apiInfo() {
    	
       return new ApiInfo(
    		      "Registration for GECO - Api Documentation",
    		      "Api Documentation",
    		      "1.0",
    		      "urn:tos",
    		      new Contact("Gianluca D'Agosta", "http://www.smartenergycommunity.it",""),
    		      "Apache 2.0",
    		      "http://www.apache.org/licenses/LICENSE-2.0",
    		      new ArrayList<>());
    }
}