package com.ease.gsms.server;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ApiDocumentationConfig {

    @Bean
    public OpenAPI api() {

        return new OpenAPI()
                .addSecurityItem(
                        new SecurityRequirement()
                                .addList("api-key", "X-Api-Key")
                )
                .components(
                        new Components()
                                .addSecuritySchemes(
                                        "api-key",
                                        new SecurityScheme()
                                                .name("X-Api-Key")
                                                .in(SecurityScheme.In.HEADER)
                                                .type(SecurityScheme.Type.APIKEY)
                                )
                )
                .info(new Info()
                        .title("SMS dispatch service")
                        .description("")
                        .version("V1.0.0")
                        .contact(
                                new Contact()
                                        .name("Val Rosca")
                                        .email("vrosca@equityjunction.co.uk")
                                        .url("https://equityjunction.co.uk")
                        ).license(
                                new License()
                                        .name("Privat")
                                        .url("https://en.wikipedia.org/wiki/Proprietary_software")
                        )
                );

    }

}