package com.bb.config;

// 중요: 패키지 경로에 .models 가 추가되었습니다.
import org.springdoc.core.models.GroupedOpenApi; 
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.servers.Server;

@Configuration
@OpenAPIDefinition(
    servers = { 
        @Server(url = "https://oprvender.com"),  
        @Server(url = "http://localhost"),  
        @Server(url = "http://lz.akrra.cc") 
    }, 
    info = @Info(title = "My API", version = "v1")
)
@SecurityScheme(
    name = "Authorization",
    scheme = "basic", 
    type = SecuritySchemeType.APIKEY, 
    in = SecuritySchemeIn.HEADER
)
public class OpenapiConfig {

    @Bean
    public GroupedOpenApi publicOpenAPI() {
        return GroupedOpenApi.builder()
                .group("front")
                .packagesToScan("com.bb.front")
                .build();
    }
    
    @Bean
    public GroupedOpenApi adminAPI() {
        return GroupedOpenApi.builder()
                .group("admin")
                .packagesToScan("com.bb.admin")
                .build();
    }
    
    @Bean
    public GroupedOpenApi commonAPI() {
        return GroupedOpenApi.builder()
                .group("common")
                .packagesToScan("com.bb.common")
                .build();
    }
}