package com.kospo.talk.config.swagger;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
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 SwaggerConfig {

    @Bean
    public OpenAPI openAPI() {
//        return new OpenAPI()
//                .info(apiInfo())
//                .components(new Components().addSecuritySchemes("basicScheme", new SecurityScheme()
//                        .type(SecurityScheme.Type.HTTP).scheme("basic")));
//    }

        return new OpenAPI()
            .info(apiInfo())
            .components(new Components()
                    .addSecuritySchemes("custom-header", new SecurityScheme()
                            .type(SecurityScheme.Type.APIKEY)
                            .in(SecurityScheme.In.HEADER)
                            .name("Authentication")))
                .addSecurityItem(new SecurityRequirement().addList("custom-header"));
    }



    private Info apiInfo() {
        return new Info()
                .title("헬프톡")
                .description("헬프톡 api")
                .version("1.0.0");
    }
}
