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:
@@ -1296,7 +1296,20 @@ func (h *OrganizationHandler) ListAgentShares(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"shares": response, "total": len(response)}})
|
||||
}
|
||||
|
||||
// RemoveAgentShare removes an agent share
|
||||
// RemoveAgentShare removes an agent share.
|
||||
//
|
||||
// RemoveAgentShare godoc
|
||||
// @Summary 取消智能体共享
|
||||
// @Description 从智能体的共享列表中移除指定共享关系
|
||||
// @Tags 组织
|
||||
// @Produce json
|
||||
// @Param id path string true "智能体 ID"
|
||||
// @Param share_id path string true "共享记录 ID"
|
||||
// @Success 200 {object} map[string]interface{} "success: true"
|
||||
// @Failure 403 {object} apperrors.AppError "无权限"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /agents/{id}/shares/{share_id} [delete]
|
||||
func (h *OrganizationHandler) RemoveAgentShare(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
shareID := c.Param("share_id")
|
||||
@@ -1309,7 +1322,19 @@ func (h *OrganizationHandler) RemoveAgentShare(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": "Share removed successfully"})
|
||||
}
|
||||
|
||||
// ListOrgAgentShares lists all agents shared to an organization
|
||||
// ListOrgAgentShares lists all agents shared to an organization.
|
||||
//
|
||||
// ListOrgAgentShares godoc
|
||||
// @Summary 获取共享到本组织的智能体
|
||||
// @Description 返回所有被共享到指定组织的智能体(含我的有效权限)
|
||||
// @Tags 组织
|
||||
// @Produce json
|
||||
// @Param id path string true "组织 ID"
|
||||
// @Success 200 {object} map[string]interface{} "智能体共享列表 + total"
|
||||
// @Failure 403 {object} apperrors.AppError "非组织成员"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /organizations/{id}/agent-shares [get]
|
||||
func (h *OrganizationHandler) ListOrgAgentShares(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
orgID := c.Param("id")
|
||||
@@ -1370,7 +1395,18 @@ func (h *OrganizationHandler) ListOrgAgentShares(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"shares": response, "total": len(response)}})
|
||||
}
|
||||
|
||||
// ListSharedAgents lists agents shared to the current user
|
||||
// ListSharedAgents lists agents shared to the current user.
|
||||
//
|
||||
// ListSharedAgents godoc
|
||||
// @Summary 获取我可访问的共享智能体
|
||||
// @Description 返回所有共享给当前用户所在组织的智能体
|
||||
// @Tags 组织
|
||||
// @Produce json
|
||||
// @Success 200 {object} map[string]interface{} "智能体列表 + total"
|
||||
// @Failure 500 {object} apperrors.AppError "服务器错误"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /shared-agents [get]
|
||||
func (h *OrganizationHandler) ListSharedAgents(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
userID := c.GetString(types.UserIDContextKey.String())
|
||||
|
||||
Reference in New Issue
Block a user