Cleanup openapi generation (#4331)

Co-authored-by: oauth <woodpecker-bot@obermui.de>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Anbraten
2024-11-23 09:17:19 +01:00
committed by GitHub
parent 8e0aac4cab
commit 07c8765b72
26 changed files with 296 additions and 235 deletions

View File

@@ -20,10 +20,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
swagger_files "github.com/swaggo/files"
openapi_files "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"go.woodpecker-ci.org/woodpecker/v2/cmd/server/docs"
"go.woodpecker-ci.org/woodpecker/v2/cmd/server/openapi"
"go.woodpecker-ci.org/woodpecker/v2/server"
"go.woodpecker-ci.org/woodpecker/v2/server/api"
"go.woodpecker-ci.org/woodpecker/v2/server/api/metrics"
@@ -78,9 +78,9 @@ func Load(noRouteHandler http.HandlerFunc, middleware ...gin.HandlerFunc) http.H
}
func setupSwaggerConfigAndRoutes(e *gin.Engine) {
docs.SwaggerInfo.Host = getHost(server.Config.Server.Host)
docs.SwaggerInfo.BasePath = server.Config.Server.RootPath + "/api"
e.GET(server.Config.Server.RootPath+"/swagger/*any", ginSwagger.WrapHandler(swagger_files.Handler))
openapi.SwaggerInfo.Host = getHost(server.Config.Server.Host)
openapi.SwaggerInfo.BasePath = server.Config.Server.RootPath + "/api"
e.GET(server.Config.Server.RootPath+"/swagger/*any", ginSwagger.WrapHandler(openapi_files.Handler))
}
func getHost(s string) string {