zhufuyi / sponge

Sponge is a powerful Go development framework, it's easy to develop web, gRPC and microservice projects.
https://go-sponge.com
MIT License
1.44k stars 142 forks source link

生成文档时swag会报错 #29

Closed lirixiang closed 1 month ago

lirixiang commented 7 months ago

Describe the bug 生成文档时swag会报错

To Reproduce Steps to reproduce the behavior, if applicable:

  1. The code is

    // @title ChatGPT_MJ_aggregation_next api docs
    // @description http server api docs
    // @schemes http https
    // @version 2.0
    // @host localhost:8080
    // @securityDefinitions.apikey BearerAuth
    // @in header
    // @name Authorization
    // @description "Type Bearer your-jwt-token" to Value
    func main() {
    initial.InitApp()
    services := initial.CreateServices()
    closes := initial.Close(services)
    
    a := app.New(services, closes)
    a.Run()
    }
    
  2. The error is

    // @description "Type Bearer your-jwt-token" to Value
    

    3.将// @description "Type Bearer your-jwt-token" to Value 改成 // @description Type Bearer your-jwt-token to Value 可以解决

zhufuyi commented 7 months ago

生成代码是下面这样,没有报错

// @description Type "Bearer your-jwt-token" to Value

是不是你手动改为下面这样导致swag报的错误呢

// @description "Type Bearer your-jwt-token" to Value
lirixiang commented 7 months ago
image image

用浏览器抓取了一下,是会报错

zhufuyi commented 7 months ago

我用的swag版本是v1.8.12,生成swagger文档时,"会被转义\",因此不会报错。