调试文档集成
This commit is contained in:
@ -102,7 +102,22 @@ func (s *server) Group(routerPrefix string, middlewareList []gin.HandlerFunc, cL
|
||||
//
|
||||
// Date : 21:45 2025/2/15
|
||||
func (s *server) SwaggerUI() {
|
||||
swaggerInstance := NewSwaggerUI(s.docInstance, SwaggerUIThemeDefault)
|
||||
swaggerInstance := NewSwaggerUI(s.docInstance, SwaggerUIThemeKnife4go)
|
||||
s.router.GET("/swagger-resources", func(ctx *gin.Context) { // lucky UI获取分组信息
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*") // 允许访问所有域
|
||||
ctx.JSON(http.StatusOK, []map[string]any{
|
||||
{
|
||||
"name": "服务文档",
|
||||
"url": "/swagger-ui/doc/openapi.json",
|
||||
"swaggerVersion": consts.SwaggerDocVersion3,
|
||||
},
|
||||
})
|
||||
// ctx.JSON(http.StatusOK, swaggerInstance.docInstance.Data())
|
||||
})
|
||||
s.router.GET("/swagger-ui/doc/openapi.json", func(ctx *gin.Context) {
|
||||
ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*") // 允许访问所有域
|
||||
ctx.JSON(http.StatusOK, swaggerInstance.docInstance.Data())
|
||||
})
|
||||
s.router.GET("/doc/swagger/*any", func(ctx *gin.Context) {
|
||||
if ctx.Request.RequestURI == "/doc/swagger/doc.json" {
|
||||
// 默认swagger, 通过此接口读取文档数据
|
||||
|
Reference in New Issue
Block a user