Open gjxgjxgjxgjx opened 7 months ago
when i run 'swag init', no api info has been generated in swagger.json
swag.exe version v1.16.3 go version go1.22.1 windows/amd64 i use the examples provided on the official website and filled in the correct package name.
package main import ( "net/http" docs "oj/docs" "github.com/gin-gonic/gin" swaggerfiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" ) // @BasePath /api/v1 // PingExample godoc // @Summary ping example // @Schemes // @Description do ping // @Tags example // @Accept json // @Produce json // @Success 200 {string} Helloworld // @Router /example/helloworld [get] func Helloworld(g *gin.Context) { g.JSON(http.StatusOK, "helloworld") } func main() { r := gin.Default() docs.SwaggerInfo.BasePath = "/api/v1" v1 := r.Group("/api/v1") { eg := v1.Group("/example") { eg.GET("/helloworld", Helloworld) } } r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) r.Run(":8080") }
I am also in the same situation, and it can detect annotation information on the main function, but it cannot scan API information with added annotations. Have you resolved it now?
when i run 'swag init', no api info has been generated in swagger.json
swag.exe version v1.16.3 go version go1.22.1 windows/amd64 i use the examples provided on the official website and filled in the correct package name.