Implement comprehensive API documentation system

 Features:
- Comprehensive Pydantic response models with examples
- Enhanced FastAPI configuration with rich OpenAPI metadata
- Centralized error handling with standardized error codes
- Professional Swagger UI styling and branding
- Health check endpoints with detailed component status
- Type-safe request/response models for all endpoints

📊 Coverage:
- Agent Management API fully documented
- Standardized error responses across all endpoints
- Interactive API documentation with try-it-now functionality
- Custom OpenAPI schema with authentication schemes

🛠️ Technical Improvements:
- Created app/models/responses.py with comprehensive models
- Added app/core/error_handlers.py for centralized error handling
- Enhanced app/api/agents.py with detailed documentation
- Custom documentation configuration in app/docs_config.py
- Global exception handlers for consistent error responses

🌐 Access Points:
- Swagger UI: /docs
- ReDoc: /redoc
- OpenAPI JSON: /openapi.json

This establishes professional-grade API documentation that matches
Hive's technical excellence and provides developers with comprehensive,
interactive documentation for efficient integration.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-07-12 10:21:08 +10:00
parent 8619b75296
commit ca18476efc
16 changed files with 1868 additions and 152 deletions

View File

@@ -35,45 +35,45 @@ export class HiveClient {
}
// Agent Management
async getAgents() {
const response = await this.api.get('/api/agents');
const response = await this.api.get('/agents');
return response.data.agents || [];
}
async registerAgent(agentData) {
const response = await this.api.post('/api/agents', agentData);
const response = await this.api.post('/agents', agentData);
return response.data;
}
// CLI Agent Management
async getCliAgents() {
const response = await this.api.get('/api/cli-agents/');
const response = await this.api.get('/cli-agents/');
return response.data || [];
}
async registerCliAgent(agentData) {
const response = await this.api.post('/api/cli-agents/register', agentData);
const response = await this.api.post('/cli-agents/register', agentData);
return response.data;
}
async registerPredefinedCliAgents() {
const response = await this.api.post('/api/cli-agents/register-predefined');
const response = await this.api.post('/cli-agents/register-predefined');
return response.data;
}
async healthCheckCliAgent(agentId) {
const response = await this.api.post(`/api/cli-agents/${agentId}/health-check`);
const response = await this.api.post(`/cli-agents/${agentId}/health-check`);
return response.data;
}
async getCliAgentStatistics() {
const response = await this.api.get('/api/cli-agents/statistics/all');
const response = await this.api.get('/cli-agents/statistics/all');
return response.data;
}
async unregisterCliAgent(agentId) {
const response = await this.api.delete(`/api/cli-agents/${agentId}`);
const response = await this.api.delete(`/cli-agents/${agentId}`);
return response.data;
}
// Task Management
async createTask(taskData) {
const response = await this.api.post('/api/tasks', taskData);
const response = await this.api.post('/tasks', taskData);
return response.data;
}
async getTask(taskId) {
const response = await this.api.get(`/api/tasks/${taskId}`);
const response = await this.api.get(`/tasks/${taskId}`);
return response.data;
}
async getTasks(filters) {
@@ -84,33 +84,33 @@ export class HiveClient {
params.append('agent', filters.agent);
if (filters?.limit)
params.append('limit', filters.limit.toString());
const response = await this.api.get(`/api/tasks?${params}`);
const response = await this.api.get(`/tasks?${params}`);
return response.data.tasks || [];
}
// Workflow Management
async getWorkflows() {
const response = await this.api.get('/api/workflows');
const response = await this.api.get('/workflows');
return response.data.workflows || [];
}
async createWorkflow(workflowData) {
const response = await this.api.post('/api/workflows', workflowData);
const response = await this.api.post('/workflows', workflowData);
return response.data;
}
async executeWorkflow(workflowId, inputs) {
const response = await this.api.post(`/api/workflows/${workflowId}/execute`, { inputs });
const response = await this.api.post(`/workflows/${workflowId}/execute`, { inputs });
return response.data;
}
// Monitoring and Status
async getClusterStatus() {
const response = await this.api.get('/api/status');
const response = await this.api.get('/status');
return response.data;
}
async getMetrics() {
const response = await this.api.get('/api/metrics');
const response = await this.api.get('/metrics');
return response.data;
}
async getExecutions(workflowId) {
const url = workflowId ? `/api/executions?workflow_id=${workflowId}` : '/api/executions';
const url = workflowId ? `/executions?workflow_id=${workflowId}` : '/executions';
const response = await this.api.get(url);
return response.data.executions || [];
}

File diff suppressed because one or more lines are too long

View File

@@ -99,18 +99,18 @@ export class HiveClient {
// Agent Management
async getAgents(): Promise<Agent[]> {
const response = await this.api.get('/api/agents');
const response = await this.api.get('/agents');
return response.data.agents || [];
}
async registerAgent(agentData: Partial<Agent>): Promise<{ agent_id: string }> {
const response = await this.api.post('/api/agents', agentData);
const response = await this.api.post('/agents', agentData);
return response.data;
}
// CLI Agent Management
async getCliAgents(): Promise<Agent[]> {
const response = await this.api.get('/api/cli-agents/');
const response = await this.api.get('/cli-agents/');
return response.data || [];
}
@@ -125,27 +125,27 @@ export class HiveClient {
command_timeout?: number;
ssh_timeout?: number;
}): Promise<{ agent_id: string; endpoint: string; health_check?: any }> {
const response = await this.api.post('/api/cli-agents/register', agentData);
const response = await this.api.post('/cli-agents/register', agentData);
return response.data;
}
async registerPredefinedCliAgents(): Promise<{ results: any[] }> {
const response = await this.api.post('/api/cli-agents/register-predefined');
const response = await this.api.post('/cli-agents/register-predefined');
return response.data;
}
async healthCheckCliAgent(agentId: string): Promise<any> {
const response = await this.api.post(`/api/cli-agents/${agentId}/health-check`);
const response = await this.api.post(`/cli-agents/${agentId}/health-check`);
return response.data;
}
async getCliAgentStatistics(): Promise<any> {
const response = await this.api.get('/api/cli-agents/statistics/all');
const response = await this.api.get('/cli-agents/statistics/all');
return response.data;
}
async unregisterCliAgent(agentId: string): Promise<{ success: boolean }> {
const response = await this.api.delete(`/api/cli-agents/${agentId}`);
const response = await this.api.delete(`/cli-agents/${agentId}`);
return response.data;
}
@@ -155,12 +155,12 @@ export class HiveClient {
priority: number;
context: Record<string, any>;
}): Promise<Task> {
const response = await this.api.post('/api/tasks', taskData);
const response = await this.api.post('/tasks', taskData);
return response.data;
}
async getTask(taskId: string): Promise<Task> {
const response = await this.api.get(`/api/tasks/${taskId}`);
const response = await this.api.get(`/tasks/${taskId}`);
return response.data;
}
@@ -174,39 +174,39 @@ export class HiveClient {
if (filters?.agent) params.append('agent', filters.agent);
if (filters?.limit) params.append('limit', filters.limit.toString());
const response = await this.api.get(`/api/tasks?${params}`);
const response = await this.api.get(`/tasks?${params}`);
return response.data.tasks || [];
}
// Workflow Management
async getWorkflows(): Promise<any[]> {
const response = await this.api.get('/api/workflows');
const response = await this.api.get('/workflows');
return response.data.workflows || [];
}
async createWorkflow(workflowData: Record<string, any>): Promise<{ workflow_id: string }> {
const response = await this.api.post('/api/workflows', workflowData);
const response = await this.api.post('/workflows', workflowData);
return response.data;
}
async executeWorkflow(workflowId: string, inputs?: Record<string, any>): Promise<{ execution_id: string }> {
const response = await this.api.post(`/api/workflows/${workflowId}/execute`, { inputs });
const response = await this.api.post(`/workflows/${workflowId}/execute`, { inputs });
return response.data;
}
// Monitoring and Status
async getClusterStatus(): Promise<ClusterStatus> {
const response = await this.api.get('/api/status');
const response = await this.api.get('/status');
return response.data;
}
async getMetrics(): Promise<string> {
const response = await this.api.get('/api/metrics');
const response = await this.api.get('/metrics');
return response.data;
}
async getExecutions(workflowId?: string): Promise<any[]> {
const url = workflowId ? `/api/executions?workflow_id=${workflowId}` : '/api/executions';
const url = workflowId ? `/executions?workflow_id=${workflowId}` : '/executions';
const response = await this.api.get(url);
return response.data.executions || [];
}