diff --git a/internal/handler/openapi.go b/internal/handler/openapi.go index 48ab70f9..47ba37a8 100644 --- a/internal/handler/openapi.go +++ b/internal/handler/openapi.go @@ -13,21 +13,21 @@ import ( // OpenAPIHandler OpenAPI处理器 type OpenAPIHandler struct { - db *database.DB - logger *zap.Logger - resultStorage storage.ResultStorage + db *database.DB + logger *zap.Logger + resultStorage storage.ResultStorage conversationHdlr *ConversationHandler - agentHdlr *AgentHandler + agentHdlr *AgentHandler } // NewOpenAPIHandler 创建新的OpenAPI处理器 func NewOpenAPIHandler(db *database.DB, logger *zap.Logger, resultStorage storage.ResultStorage, conversationHdlr *ConversationHandler, agentHdlr *AgentHandler) *OpenAPIHandler { return &OpenAPIHandler{ - db: db, - logger: logger, - resultStorage: resultStorage, + db: db, + logger: logger, + resultStorage: resultStorage, conversationHdlr: conversationHdlr, - agentHdlr: agentHdlr, + agentHdlr: agentHdlr, } } @@ -487,7 +487,7 @@ func (h *OpenAPIHandler) GetOpenAPISpec(c *gin.Context) { }, }, }, - "/api/agent-loop": map[string]interface{}{ + "/api/agent-loop/stream": map[string]interface{}{ "post": map[string]interface{}{ "tags": []string{"对话交互"}, "summary": "发送消息并获取AI回复(核心端点)", @@ -572,7 +572,6 @@ func (h *OpenAPIHandler) GetOpenAPISpec(c *gin.Context) { c.JSON(http.StatusOK, spec) } - // GetConversationResults 获取对话结果(OpenAPI端点) // 注意:创建对话和获取对话详情直接使用标准的 /api/conversations 端点 // 这个端点只是为了提供结果聚合功能 diff --git a/web/static/js/api-docs.js b/web/static/js/api-docs.js index 5c7fa175..568e11c7 100644 --- a/web/static/js/api-docs.js +++ b/web/static/js/api-docs.js @@ -224,7 +224,7 @@ function renderParameters(endpoint) { if (params.length === 0) return ''; const rows = params.map(param => { - const required = param.required ? '必需' : '可选'; + const required = param.required ? '必需' : '可选'; return ` ${param.name} @@ -238,19 +238,21 @@ function renderParameters(endpoint) { return `
参数
- - - - - - - - - - - ${rows} - -
参数名类型描述必需
+
+ + + + + + + + + + + ${rows} + +
参数名类型描述必需
+
`; } @@ -279,7 +281,7 @@ function renderRequestBody(endpoint) { const prop = schema.properties[key]; const required = requiredFields.includes(key) ? '必需' - : '可选'; + : '可选'; // 处理嵌套类型 let typeDisplay = prop.type || 'object'; @@ -308,20 +310,22 @@ function renderRequestBody(endpoint) { if (rows) { paramsTable = ` - - - - - - - - - - - - ${rows} - -
参数名类型描述必需示例
+
+ + + + + + + + + + + + ${rows} + +
参数名类型描述必需示例
+
`; } } diff --git a/web/templates/api-docs.html b/web/templates/api-docs.html index 3df5a1ce..2ec5ba3a 100644 --- a/web/templates/api-docs.html +++ b/web/templates/api-docs.html @@ -233,6 +233,12 @@ margin-bottom: 24px; } + .api-table-wrapper { + overflow-x: auto; + width: 100%; + -webkit-overflow-scrolling: touch; + } + .api-section:last-child { margin-bottom: 0; } @@ -257,6 +263,7 @@ width: 100%; border-collapse: collapse; font-size: 0.875rem; + table-layout: auto; } .api-params-table th, @@ -266,6 +273,25 @@ border-bottom: 1px solid var(--border-color); } + /* 参数名、类型、必需、示例列不换行 */ + .api-params-table th:nth-child(1), + .api-params-table td:nth-child(1), + .api-params-table th:nth-child(2), + .api-params-table td:nth-child(2), + .api-params-table th:nth-child(4), + .api-params-table td:nth-child(4), + .api-params-table th:nth-child(5), + .api-params-table td:nth-child(5) { + white-space: nowrap; + } + + /* 描述列允许换行 */ + .api-params-table th:nth-child(3), + .api-params-table td:nth-child(3) { + white-space: normal; + word-break: break-word; + } + .api-params-table th { background: var(--bg-secondary); font-weight: 600; @@ -293,6 +319,12 @@ font-weight: 600; } + .api-param-optional { + color: var(--text-muted); + font-size: 0.75rem; + font-weight: 400; + } + .api-test-section { margin-top: 24px; padding-top: 24px;