package com.unicorn.hgzero.notification.config;

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.servers.Server;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * Swagger/OpenAPI 설정
 *
 * API 문서 자동 생성 및 Swagger UI 설정
 * SpringDoc OpenAPI 3.0 사용
 *
 * @author 준호 (Backend Developer)
 * @version 1.0
 * @since 2025-10-23
 */
@Slf4j
@Configuration
public class SwaggerConfig {

    @Value("${spring.application.name:notification}")
    private String applicationName;

    /**
     * OpenAPI 설정 Bean 생성
     *
     * @return OpenAPI 설정
     */
    @Bean
    public OpenAPI openAPI() {
        log.info("OpenAPI 설정 생성 중...");

        OpenAPI openAPI = new OpenAPI()
            .info(new Info()
                .title("HGZero Notification Service API")
                .description("회의 초대 및 Todo 할당 알림 발송 서비스 API")
                .version("1.0.0")
                .contact(new Contact()
                    .name("Backend Team")
                    .email("backend@hgzero.com"))
                .license(new License()
                    .name("Apache 2.0")
                    .url("https://www.apache.org/licenses/LICENSE-2.0.html")))
            .servers(List.of(
                new Server()
                    .url("http://localhost:8080")
                    .description("Local Development Server"),
                new Server()
                    .url("https://api.hgzero.com")
                    .description("Production Server")
            ));

        log.info("OpenAPI 설정 생성 완료");

        return openAPI;
    }
}
