改进 swag go

This commit is contained in:
Twilight 2024-07-14 22:14:27 +08:00
parent 8231060f30
commit 57e57e5028
3 changed files with 31 additions and 4 deletions

View File

@ -6,4 +6,5 @@ grpc-web:
grpcwebproxy --backend_addr=localhost:8081 --run_http_server --run_tls_server=false --server_http_debug_port 18081 --allow_all_origins --server_bind_address 127.0.0.1 grpcwebproxy --backend_addr=localhost:8081 --run_http_server --run_tls_server=false --server_http_debug_port 18081 --allow_all_origins --server_bind_address 127.0.0.1
install-deps: install-deps:
go install github.com/swaggo/swag/cmd/swag@latest go install github.com/swaggo/swag/cmd/swag@latest
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest swag:
swag init -g internal/routes/router.go

View File

@ -7,6 +7,27 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// @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 /api/v1
// @securityDefinitions.basic BasicAuth
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @description Description for what is this security definition being used
func InitApiRoutes() { func InitApiRoutes() {
var router = *providers.MustGet[gin.Engine]() var router = *providers.MustGet[gin.Engine]()

View File

@ -5,6 +5,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"framework_v2/internal/cmd" "framework_v2/internal/cmd"
"framework_v2/internal/providers"
"io/fs" "io/fs"
"os" "os"
"os/exec" "os/exec"
@ -17,10 +18,14 @@ const frameworkModuleName = "framework_v2"
func main() { func main() {
flag.Parse() flag.Parse()
var config = providers.MustGet[providers.GlobalConfig]()
if config.DebugMode.Enable {
if len(os.Args) == 2 && os.Args[1] == "setup" { if len(os.Args) == 2 && os.Args[1] == "setup" {
setup() setup()
return return
} }
}
cmd.Execute() cmd.Execute()
} }