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:
@@ -155,6 +155,21 @@ func (h *IMHandler) ListAllIMChannels(c *gin.Context) {
|
||||
}
|
||||
|
||||
// UpdateIMChannel updates an IM channel.
|
||||
//
|
||||
// UpdateIMChannel godoc
|
||||
// @Summary 更新 IM 渠道
|
||||
// @Description 更新指定 IM 渠道的名称、模式、知识库、凭证或启用状态
|
||||
// @Tags IM 渠道
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "渠道 ID"
|
||||
// @Param request body map[string]interface{} true "更新字段(name/mode/output_mode/knowledge_base_id/credentials/enabled)"
|
||||
// @Success 200 {object} map[string]interface{} "更新后的渠道"
|
||||
// @Failure 400 {object} map[string]interface{} "请求参数错误"
|
||||
// @Failure 404 {object} map[string]interface{} "渠道不存在"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /im-channels/{id} [put]
|
||||
func (h *IMHandler) UpdateIMChannel(c *gin.Context) {
|
||||
channelID := c.Param("id")
|
||||
if channelID == "" {
|
||||
@@ -220,6 +235,19 @@ func (h *IMHandler) UpdateIMChannel(c *gin.Context) {
|
||||
}
|
||||
|
||||
// DeleteIMChannel deletes an IM channel.
|
||||
//
|
||||
// DeleteIMChannel godoc
|
||||
// @Summary 删除 IM 渠道
|
||||
// @Description 删除指定 IM 渠道
|
||||
// @Tags IM 渠道
|
||||
// @Produce json
|
||||
// @Param id path string true "渠道 ID"
|
||||
// @Success 200 {object} map[string]interface{} "success: true"
|
||||
// @Failure 400 {object} map[string]interface{} "请求参数错误"
|
||||
// @Failure 404 {object} map[string]interface{} "渠道不存在"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /im-channels/{id} [delete]
|
||||
func (h *IMHandler) DeleteIMChannel(c *gin.Context) {
|
||||
channelID := c.Param("id")
|
||||
if channelID == "" {
|
||||
@@ -242,6 +270,19 @@ func (h *IMHandler) DeleteIMChannel(c *gin.Context) {
|
||||
}
|
||||
|
||||
// ToggleIMChannel toggles the enabled state of an IM channel.
|
||||
//
|
||||
// ToggleIMChannel godoc
|
||||
// @Summary 启用/停用 IM 渠道
|
||||
// @Description 切换指定 IM 渠道的启用状态
|
||||
// @Tags IM 渠道
|
||||
// @Produce json
|
||||
// @Param id path string true "渠道 ID"
|
||||
// @Success 200 {object} map[string]interface{} "更新后的渠道"
|
||||
// @Failure 400 {object} map[string]interface{} "请求参数错误"
|
||||
// @Failure 404 {object} map[string]interface{} "渠道不存在"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /im-channels/{id}/toggle [post]
|
||||
func (h *IMHandler) ToggleIMChannel(c *gin.Context) {
|
||||
channelID := c.Param("id")
|
||||
if channelID == "" {
|
||||
@@ -268,6 +309,19 @@ func (h *IMHandler) ToggleIMChannel(c *gin.Context) {
|
||||
|
||||
// IMCallback handles IM platform callback requests for a specific channel.
|
||||
// Route: POST /api/v1/im/callback/:channel_id
|
||||
//
|
||||
// IMCallback godoc
|
||||
// @Summary IM 平台回调
|
||||
// @Description 接收各 IM 平台的事件回调;走平台自身签名校验,不使用 API Key
|
||||
// @Tags IM 回调
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param channel_id path string true "渠道 ID"
|
||||
// @Success 200 {object} map[string]interface{} "处理结果"
|
||||
// @Failure 400 {object} map[string]interface{} "请求参数错误"
|
||||
// @Failure 401 {object} map[string]interface{} "签名校验失败"
|
||||
// @Router /im/callback/{channel_id} [get]
|
||||
// @Router /im/callback/{channel_id} [post]
|
||||
func (h *IMHandler) IMCallback(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
channelID := c.Param("channel_id")
|
||||
|
||||
Reference in New Issue
Block a user