package com.pablotj.ai.chat.infrastructure.configuration;

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 java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * OpenAPI/Swagger configuration for API documentation.
 */
@Configuration
public class OpenApiConfiguration {

    @Value("${server.servlet.context-path:/api}")
    private String contextPath;

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("AI Chat Platform API")
                        .description("Enterprise-grade AI Chat Platform with offline capabilities")
                        .version("1.0.0")
                        .contact(new Contact()
                                .name("Pablo TJ")
                                .email("contact@pablotj.com")
                                .url("https://github.com/pablotj"))
                        .license(new License()
                                .name("MIT License")
                                .url("https://opensource.org/licenses/MIT")))
                .servers(List.of(
                        new Server()
                                .url("http://localhost:8080" + contextPath)
                                .description("Development server"),
                        new Server()
                                .url("https://api.ai-chat-platform.com" + contextPath)
                                .description("Production server")));
    }
}
