From dba91f0269bd0ae18290a3292d4a6d77a3b4446c Mon Sep 17 00:00:00 2001 From: spacelocust <39099403+Spacelocust@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:44:18 +0200 Subject: [PATCH] fix: swagger --- .github/workflows/docker-api.yml | 2 +- .github/workflows/docker-migrations.yml | 2 +- api/internal/server/server.go | 10 ++++++++-- api/main.go | 14 -------------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker-api.yml b/.github/workflows/docker-api.yml index 189872d..dedba35 100644 --- a/.github/workflows/docker-api.yml +++ b/.github/workflows/docker-api.yml @@ -50,7 +50,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} push: ${{ github.event_name != 'pull_request' }} tags: spacelocust/fd-api:latest - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 cache-from: type=gha cache-to: type=gha,mode=max env: diff --git a/.github/workflows/docker-migrations.yml b/.github/workflows/docker-migrations.yml index aabcb26..25a3a29 100644 --- a/.github/workflows/docker-migrations.yml +++ b/.github/workflows/docker-migrations.yml @@ -47,7 +47,7 @@ jobs: builder: ${{ steps.buildx.outputs.name }} push: ${{ github.event_name != 'pull_request' }} tags: spacelocust/fd-migrations:latest - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 cache-from: type=gha cache-to: type=gha,mode=max env: diff --git a/api/internal/server/server.go b/api/internal/server/server.go index d486f87..2ef6208 100644 --- a/api/internal/server/server.go +++ b/api/internal/server/server.go @@ -69,8 +69,14 @@ func NewServer() *http.Server { log.Fatal(err) } - docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", os.Getenv("API_DOMAIN"), os.Getenv("API_PORT")) - docs.SwaggerInfo.Schemes = []string{"http", "https"} + // Set up the Swagger documentation + if os.Getenv("API_ENV") == "production" { + docs.SwaggerInfo.Host = os.Getenv("API_DOMAIN") + docs.SwaggerInfo.Schemes = []string{"https"} + } else { + docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", os.Getenv("API_DOMAIN"), os.Getenv("API_PORT")) + docs.SwaggerInfo.Schemes = []string{"http"} + } // Declare Server config server := &http.Server{ diff --git a/api/main.go b/api/main.go index 20b81f0..af53bb3 100644 --- a/api/main.go +++ b/api/main.go @@ -1,12 +1,8 @@ package main import ( - "fmt" - "os" - _ "ariga.io/atlas-provider-gorm/gormschema" "github.com/Spacelocust/for-democracy/cmd" - "github.com/Spacelocust/for-democracy/docs" ) // @BasePath / @@ -19,15 +15,5 @@ import ( // @license.name Apache 2.0 // @license.url http://www.apache.org/licenses/LICENSE-2.0.html func main() { - - // Set up the Swagger documentation - if os.Getenv("API_ENV") == "production" { - docs.SwaggerInfo.Host = os.Getenv("API_DOMAIN") - docs.SwaggerInfo.Schemes = []string{"https"} - } else { - docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", os.Getenv("API_DOMAIN"), os.Getenv("API_PORT")) - docs.SwaggerInfo.Schemes = []string{"http"} - } - cmd.RunCLI() }