use utoipa::OpenApi;
use common_contracts::messages::*;
use common_contracts::observability::*;
use common_contracts::config_models::*;
use crate::api;

#[derive(OpenApi)]
#[openapi(
    paths(
        api::health_check,
        api::start_workflow,
        api::get_task_progress,
        api::resolve_symbol,
        api::get_llm_providers_config,
        api::update_llm_providers_config,
        api::get_analysis_template_sets,
        api::update_analysis_template_sets,
        api::get_data_sources_config,
        api::update_data_sources_config,
        api::test_data_source_config,
        api::test_llm_config,
        api::discover_models,
        api::discover_models_preview,
        api::get_data_source_schema, // New endpoint
    ),
    components(
        schemas(
            // Workflow
            StartWorkflowCommand,
            WorkflowEvent,
            WorkflowDag,
            TaskNode,
            TaskDependency,
            TaskType,
            TaskStatus,
            // Observability
            TaskProgress,
            ServiceStatus,
            HealthStatus,
            ObservabilityTaskStatus,
            // Configs
            LlmProvider,
            LlmModel,
            AnalysisTemplateSet,
            AnalysisModuleConfig,
            DataSourceConfig,
            DataSourceProvider,
            // Request/Response
            api::DataRequest,
            api::RequestAcceptedResponse,
            api::SymbolResolveRequest,
            api::SymbolResolveResponse,
            api::TestConfigRequest,
            api::TestLlmConfigRequest,
            api::DataSourceSchemaResponse,
            api::DataSourceProviderSchema,
            api::ConfigFieldSchema,
        )
    ),
    tags(
        (name = "workflow", description = "Workflow management endpoints"),
        (name = "config", description = "Configuration management endpoints"),
        (name = "tools", description = "Utility tools"),
        (name = "observability", description = "System observability"),
    )
)]
pub struct ApiDoc;

