docs(api): add and fix swag annotations on handlers
将 swag 注解覆盖率从 ~88% 提升到 100%,并修复审计中发现的若干既有
注解 bug。
新增注解(24 个):
- im.go: 4 (UpdateIMChannel/DeleteIMChannel/ToggleIMChannel/IMCallback)
其中 IMCallback 同时注册 GET 和 POST,两个方法都加了 @Router 声明。
- web_search.go: 1 (GetProviders)
- web_search_provider.go: 6
- wechat_qrcode.go: 2
- weknoracloud.go: 2
- knowledge.go: 2 (MoveKnowledge/GetKnowledgeMoveProgress)
- knowledgebase.go: 1 (ListMoveTargets)
- organization.go: 3 (ListSharedAgents/ListOrgAgentShares/RemoveAgentShare)
- mcp_service.go: 2 (SetMCPToolApproval/ResolveToolApproval)
- chunker_debug.go: 1 (PreviewChunking)
修复既有注解 bug(12 处):
- initialization.go: 10 个 @Router 路径与真实路由不符
(e.g. /initialization/kb/{kbId}/config → /initialization/config/{kbId}
/initialization/fabri/tag GET → /initialization/extract/fabri-tag POST)
- session/stream.go: ContinueStream 路径
/sessions/{session_id}/continue → /sessions/continue-stream/{session_id}
- mcp_service.go: ResolveToolApproval 请求体 {approve: bool}
→ {decision: "approve"|"reject", reason?, modified_args?}
收敛响应 schema 到已有命名 struct(之前用 map[string]interface{}):
- knowledge.go MoveKnowledge → handler.MoveKnowledgeResponse
- knowledge.go GetKnowledgeMoveProgress → types.KnowledgeMoveProgress
- web_search_provider.go GetProvider/UpdateProvider → types.WebSearchProviderEntity
- initialization.go InitializeByKB → handler.InitializationRequest
- initialization.go 三个 model-test endpoint → handler.ModelTestRequest
修正 organization.go 中 errors.AppError 应使用 apperrors 别名(该文件
stdlib errors 未别名化)。
不补 /files 和 /api/v1/files/presigned 内联闭包路由(文件服务,非业务 REST)。
Refs #890 #1049 #1168
This commit is contained in:
@@ -137,7 +137,19 @@ func (h *WebSearchProviderHandler) ListProviders(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// GetProvider retrieves a single web search provider by ID
|
||||
// GetProvider retrieves a single web search provider by ID.
|
||||
//
|
||||
// GetProvider godoc
|
||||
// @Summary 获取网络搜索 Provider 详情
|
||||
// @Description 根据 ID 获取指定 provider 配置
|
||||
// @Tags 网络搜索
|
||||
// @Produce json
|
||||
// @Param id path string true "Provider ID"
|
||||
// @Success 200 {object} types.WebSearchProviderEntity "Provider 详情"
|
||||
// @Failure 404 {object} map[string]interface{} "Provider 不存在"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /web-search-providers/{id} [get]
|
||||
func (h *WebSearchProviderHandler) GetProvider(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
@@ -160,7 +172,22 @@ func (h *WebSearchProviderHandler) GetProvider(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateProvider updates a web search provider
|
||||
// UpdateProvider updates a web search provider.
|
||||
//
|
||||
// UpdateProvider godoc
|
||||
// @Summary 更新网络搜索 Provider
|
||||
// @Description 更新指定 provider 的名称/描述/参数/是否默认
|
||||
// @Tags 网络搜索
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Provider ID"
|
||||
// @Param request body handler.UpdateProviderRequest true "更新字段"
|
||||
// @Success 200 {object} types.WebSearchProviderEntity "更新后的 Provider"
|
||||
// @Failure 400 {object} map[string]interface{} "请求参数错误"
|
||||
// @Failure 404 {object} map[string]interface{} "Provider 不存在"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /web-search-providers/{id} [put]
|
||||
func (h *WebSearchProviderHandler) UpdateProvider(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
@@ -211,7 +238,19 @@ func (h *WebSearchProviderHandler) UpdateProvider(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteProvider deletes a web search provider
|
||||
// DeleteProvider deletes a web search provider.
|
||||
//
|
||||
// DeleteProvider godoc
|
||||
// @Summary 删除网络搜索 Provider
|
||||
// @Description 删除指定 provider 配置
|
||||
// @Tags 网络搜索
|
||||
// @Produce json
|
||||
// @Param id path string true "Provider ID"
|
||||
// @Success 200 {object} map[string]interface{} "success: true"
|
||||
// @Failure 404 {object} map[string]interface{} "Provider 不存在"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /web-search-providers/{id} [delete]
|
||||
func (h *WebSearchProviderHandler) DeleteProvider(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
@@ -238,7 +277,17 @@ func (h *WebSearchProviderHandler) DeleteProvider(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||||
}
|
||||
|
||||
// ListProviderTypes returns available provider types and their parameter requirements
|
||||
// ListProviderTypes returns available provider types and their parameter requirements.
|
||||
//
|
||||
// ListProviderTypes godoc
|
||||
// @Summary 获取网络搜索 Provider 类型元数据
|
||||
// @Description 返回 UI 表单需要的 provider 类型及参数定义
|
||||
// @Tags 网络搜索
|
||||
// @Produce json
|
||||
// @Success 200 {object} map[string]interface{} "provider 类型列表"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /web-search-providers/types [get]
|
||||
func (h *WebSearchProviderHandler) ListProviderTypes(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
@@ -246,7 +295,19 @@ func (h *WebSearchProviderHandler) ListProviderTypes(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// TestProviderByID tests an existing saved provider by performing a sample search
|
||||
// TestProviderByID tests an existing saved provider by performing a sample search.
|
||||
//
|
||||
// TestProviderByID godoc
|
||||
// @Summary 测试已保存的 Provider
|
||||
// @Description 使用数据库中已保存的凭证测试连通性
|
||||
// @Tags 网络搜索
|
||||
// @Produce json
|
||||
// @Param id path string true "Provider ID"
|
||||
// @Success 200 {object} map[string]interface{} "测试结果"
|
||||
// @Failure 404 {object} map[string]interface{} "Provider 不存在"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /web-search-providers/{id}/test [post]
|
||||
func (h *WebSearchProviderHandler) TestProviderByID(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
@@ -278,7 +339,20 @@ type TestProviderRequest struct {
|
||||
Parameters types.WebSearchProviderParameters `json:"parameters"`
|
||||
}
|
||||
|
||||
// TestProviderRaw tests a provider with raw credentials (no persistence)
|
||||
// TestProviderRaw tests a provider with raw credentials (no persistence).
|
||||
//
|
||||
// TestProviderRaw godoc
|
||||
// @Summary 使用原始凭证测试 Provider(不落库)
|
||||
// @Description 使用前端表单中尚未保存的凭证测试连通性,用于"测试连接"按钮
|
||||
// @Tags 网络搜索
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body handler.TestProviderRequest true "{provider, parameters}"
|
||||
// @Success 200 {object} map[string]interface{} "测试结果"
|
||||
// @Failure 400 {object} map[string]interface{} "请求参数错误"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /web-search-providers/test [post]
|
||||
func (h *WebSearchProviderHandler) TestProviderRaw(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user