feat: 接口文档注册增加是否开启文档判断

This commit is contained in:
2026-01-08 23:03:24 +08:00
parent 2bdacbe924
commit aa13f55aa3

View File

@@ -259,13 +259,15 @@ func (s *server) Group(routerPrefix string, middlewareList []gin.HandlerFunc, co
routerPrefix = "/" + strings.TrimSuffix(strings.TrimPrefix(routerPrefix, "/"), "/") routerPrefix = "/" + strings.TrimSuffix(strings.TrimPrefix(routerPrefix, "/"), "/")
} }
fullUriPath := routerPrefix + "/" + strings.TrimPrefix(itemUriCfg.Path, "/") fullUriPath := routerPrefix + "/" + strings.TrimPrefix(itemUriCfg.Path, "/")
// 注册接口文档 if s.option.docConfig.Enable {
_ = openapi.DocManager.AddApiDoc(s.option.docConfig.Flag, apiDocDefine.UriConfig{ // 注册接口文档
Path: fullUriPath, _ = openapi.DocManager.AddApiDoc(s.option.docConfig.Flag, apiDocDefine.UriConfig{
RequestMethod: method, Path: fullUriPath,
TagList: itemUriCfg.TagList, RequestMethod: method,
Desc: itemUriCfg.Desc, TagList: itemUriCfg.TagList,
}, itemUriCfg.FormDataType, itemUriCfg.ResultDataType) Desc: itemUriCfg.Desc,
}, itemUriCfg.FormDataType, itemUriCfg.ResultDataType)
}
s.uriTable[fullUriPath] = itemUriCfg // 注册路由时存储 接口路径 => 接口配置的信息 s.uriTable[fullUriPath] = itemUriCfg // 注册路由时存储 接口路径 => 接口配置的信息
s.consoleOutput = append(s.consoleOutput, []any{ s.consoleOutput = append(s.consoleOutput, []any{
fullUriPath, fullUriPath,