package com.royalrangers.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
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
public class SwaggerConfig {

    @Value("${springfox.documentation.swagger.v2.title}")
    private String title;

    @Value("${springfox.documentation.swagger.v2.description}")
    private String description;

    @Value("${springfox.documentation.swagger.v2.termsOfServiceUrl}")
    private String termsOfServiceUrl;

    @Value("${springfox.documentation.swagger.v2.license}")
    private String license;

    @Value("${springfox.documentation.swagger.v2.licenseUrl}")
    private String licenseUrl;

    @Value("${springfox.documentation.swagger.v2.contactName}")
    private String contactName;

    @Value("${springfox.documentation.swagger.v2.contactUrl}")
    private String contactUrl;

    @Value("${springfox.documentation.swagger.contactEmail}")
    private String contactEmail;

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.royalrangers"))
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title(title)
                .description(description)
                .termsOfServiceUrl(termsOfServiceUrl)
                .contact(new Contact(contactName, contactUrl, contactEmail))
                .license(license)
                .licenseUrl(licenseUrl)
                .build();
    }

}

@@ -473,127 +473,353 @@
 ice.
-Contact;%0Aimport springfox.documentation.spi.DocumentationType;%0Aimport springfox.documentation.spring.web.plugins.Docket
+ApiKey;%0Aimport springfox.documentation.service.Contact;%0Aimport springfox.documentation.service.SecurityScheme;%0Aimport springfox.documentation.spi.DocumentationType;%0Aimport springfox.documentation.spring.web.plugins.Docket;%0Aimport springfox.documentation.swagger.web.ApiKeyVehicle;%0Aimport springfox.documentation.swagger.web.SecurityConfiguration
 ;%0Aim
@@ -2449,10 +2449,423 @@
 %0A    %7D%0A%0A
+    @Bean%0A    SecurityConfiguration security() %7B%0A        return new SecurityConfiguration(%0A                %22%22,%0A                %22%22,%0A                %22%22,%0A                %22%22,%0A                %22%22,%0A                ApiKeyVehicle.HEADER,%0A                %22Authorization%22,%0A                %22,%22 /*scope separator*/);%0A    %7D%0A%0A    @Bean%0A    SecurityScheme apiKey() %7B%0A        return new ApiKey(%22token%22, %22token%22, %22header%22);%0A    %7D%0A%0A
 %7D%0A

Use authorization key in swagger