Open w570955342 opened 2 years ago
// @securitydefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
securityDefinitions -> securitydefinitions
does works for me!!!!
Moving securitydefinitions annotations above main() function helped me.
Describe the bug // @title 网络检查服务 // @description 网络检查服务接口文档 // @securityDefinitions.apikey ApiKeyAuth // @in header // @name Authorization // @schemes http https // @BasePath /check // @contact.name zq // @contact.email z397435052@gmail.com func main() {}
swag v1.8.0 doc.go: // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ Version: "", Host: "", BasePath: "/check", Schemes: []string{"http", "https"}, Title: "网络检查服务", Description: "网络检查服务接口文档", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, }
swag v1.8.6 doc.go: // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ Version: "", Host: "", BasePath: "", Schemes: []string{}, Title: "网络检查服务", Description: "网络检查服务接口文档", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, }
but when I chage main.go,just add a blank line , v1.8.6 works well。 // @title 网络检查服务 // @description 网络检查服务接口文档 // @securityDefinitions.apikey ApiKeyAuth // @in header // @name Authorization
// @schemes http https // @BasePath /check // @contact.name zq // @contact.email z397435052@gmail.com func main() {}
swag v1.8.6 doc.go: // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ Version: "", Host: "", BasePath: "/check", Schemes: []string{"http", "https"}, Title: "网络检查服务", Description: "网络检查服务接口文档", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, }
To Reproduce Steps to reproduce the behavior:
Expected behavior swag v1.8.6 can work well.
Your swag version 1.8.0 and 1.8.6
Your go version go version go1.18.3 windows/amd64
Desktop (please complete the following information):