-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
The @schemes annotation correctly generates the schemes array in swagger.json and swagger.yaml, but the generated docs.go file has an empty Schemes slice in SwaggerInfo. This causes the runtime template {{ marshal .Schemes }} to render an empty array when serving Swagger UI.
To Reproduce
Steps to reproduce the behavior:
- Add // @schemes http https annotation in your main.go
- Run swag init
- Open generated docs/swagger.json - observe "schemes": ["http", "https"] is correct
- Open generated docs/docs.go - observe Schemes: []string{} is empty
Expected behavior
The Generated docs.go should contain:
var SwaggerInfo = &swag.Spec{
Schemes: []string{"http", "https"},
// ...
}
Instead, it generates:
var SwaggerInfo = &swag.Spec{
Schemes: []string{},
// ...
}
Screenshots
If applicable, add screenshots to help explain your problem.
Your swag version
v1.16.4
Your go version
go1.24.2
Desktop (please complete the following information):
- OS: Windows
Additional context
Current workaround is to set it manually at runtime.
func init() {
docs.SwaggerInfo.Schemes = []string{"http", "https"}
}