#[cfg(test)]
mod tests {
    use crate::openapi::ApiDoc;
    use utoipa::OpenApi;

    #[test]
    fn test_openapi_schema_generation() {
        let doc = ApiDoc::openapi();
        let json = doc.to_json().expect("Failed to serialize OpenAPI doc");
        
        // Basic validation
        assert!(json.contains("\"openapi\":\"3.1.0\""), "Should specify OpenAPI version");
        assert!(json.contains("\"title\":\"api-gateway\""), "Should have title");
        
        // Check key schemas exist
        assert!(json.contains("\"WorkflowEvent\""), "Should contain WorkflowEvent schema");
        assert!(json.contains("\"DataSourceConfig\""), "Should contain DataSourceConfig schema");
        assert!(json.contains("\"DataSourceSchemaResponse\""), "Should contain DataSourceSchemaResponse schema");
        assert!(json.contains("\"TaskProgress\""), "Should contain TaskProgress schema");
        
        // Check new endpoints exist
        assert!(json.contains("/v1/configs/data_sources/schema"), "Should contain schema endpoint");
        assert!(json.contains("/v1/workflow/start"), "Should contain workflow start endpoint");
        
        // Check progress field
        assert!(json.contains("\"progress\""), "Should contain progress field in TaskStateChanged (inside WorkflowEvent)");
        
        // Optional: Print for manual inspection
        // println!("{}", json);
    }
}

