package eu.dnetlib.broker;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import eu.dnetlib.common.app.AbstractDnetApp;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Tag;
import springfox.documentation.spring.web.plugins.Docket;

@SpringBootApplication
public class BrokerPublicApplication extends AbstractDnetApp {

	public static final String OA_PUBLIC_APIS = "Openaire Broker Public API";

	public static void main(final String[] args) {
		SpringApplication.run(BrokerPublicApplication.class, args);
	}

	@Override
	protected void configSwagger(final Docket docket) {

		docket.select()
			.apis(RequestHandlerSelectors.any())
			.paths(p -> p.startsWith("/"))
			.build()
			.tags(new Tag(OA_PUBLIC_APIS, OA_PUBLIC_APIS))
			.apiInfo(new ApiInfoBuilder()
				.title("OpenAIRE Public Broker API")
				.description("APIs documentation")
				.version("1.1")
				.contact(ApiInfo.DEFAULT_CONTACT)
				.license("Apache 2.0")
				.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
				.build());

	}
}
