cannot find type definition: gin.H
Author: eschcamCreated Jun 23, 2026Updated Jun 25, 2026
Describe the bug When using gin.H as the return object, an invalid type error is given
To Reproduce
// @Summary Health check
// @Description Health check
// @Tags Utility
// @Produce json
// @Success 200 {object} gin.H{"db": "healthy"}
func healthCheck(c *gin.Context) {
err := pingDb()
if err != nil {
zap.L().Error("Failed to ping DB", zap.Error(err))
c.JSON(http.StatusInternalServerError, gin.H{"db": "Failed to ping DB", "error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"db": "healthy"})
}Gives the error
swag init --parseDependency --parseInternal --parseDepth 1 -g ./router.go ─╯
2026/06/23 11:06:10 Generate swagger docs....
2026/06/23 11:06:10 Generate general API Info, search dir:./
2026/06/23 11:06:10 warning: failed to evaluate const mProfCycleWrap at /usr/local/go/src/runtime/mprof.go:179:7, reflect: call of reflect.Value.Len on zero Value
2026/06/23 11:06:10 ParseComment error in file /home/cam/git/pr-tracker-2/api/router.go for comment: '// @Success 200 {object} gin.H{"db": "healthy"}': invalid type: gin.H{Your swag version swag version v1.16.4
Your go version go version go1.26.3 linux/amd64
Desktop (please complete the following information):
- OS: Linux cachyos-x8664 7.0.12-1-cachyos
Source: swaggo/swag