[message pusher] - add swagger

This commit is contained in:
zeaslity
2024-04-23 15:25:53 +08:00
parent 16541183ef
commit 9d09c793ad
11 changed files with 605 additions and 22 deletions

View File

@@ -2,12 +2,41 @@ package main
import (
"github.com/gin-gonic/gin"
"io.wdd.message_pusher/docs"
"io.wdd.message_pusher/router"
)
import "github.com/swaggo/gin-swagger" // gin-swagger middleware
import "github.com/swaggo/files" // swagger embed files
// @title Swagger Example API
// @version 1.0
// @description This is a sample server celler server.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080
// @BasePath
// @securityDefinitions.basic BasicAuth
// @externalDocs.description OpenAPI
// @externalDocs.url https://swagger.io/resources/open-api/
func main() {
engine := gin.Default()
// programmatically set swagger info
docs.SwaggerInfo.Title = "Wdd Message Pusher"
docs.SwaggerInfo.Description = "Wdd Message Pusher Service"
docs.SwaggerInfo.Version = "1.0"
docs.SwaggerInfo.Host = "localhost:8080"
docs.SwaggerInfo.BasePath = ""
docs.SwaggerInfo.Schemes = []string{"http"}
// 强制日志颜色化
gin.ForceConsoleColor()
@@ -18,6 +47,7 @@ func main() {
router.OctopusRouter(engine)
}
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
err := engine.Run(":8080")
if err != nil {
panic(err)