整合默认swagger文档
This commit is contained in:
@ -82,4 +82,22 @@ func (s *server) Group(routerPrefix string, middlewareList []gin.HandlerFunc, cL
|
||||
}
|
||||
}
|
||||
}
|
||||
// 注册文档
|
||||
s.SwaggerUI()
|
||||
}
|
||||
|
||||
// SwaggerUI ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 21:45 2025/2/15
|
||||
func (s *server) SwaggerUI() {
|
||||
swaggerInstance := NewSwaggerUI(s.docInstance, SwaggerUIThemeDefault)
|
||||
// 默认swagger
|
||||
s.router.GET("/swagger/*any", func(ctx *gin.Context) {
|
||||
if ctx.Request.RequestURI == "/swagger/doc.json" {
|
||||
ctx.JSON(http.StatusOK, swaggerInstance.docInstance.Data())
|
||||
ctx.Abort()
|
||||
}
|
||||
}, swaggerInstance.HandleSwaggerUI())
|
||||
}
|
||||
|
Reference in New Issue
Block a user