From 7154faa7f4799cbcddd0ed540577d18a5da1d610 Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Tue, 7 Apr 2026 01:27:50 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20fix:=20correct=20Swagger=20auth?= =?UTF-8?q?=20scheme=20from=20ApiKeyAuth=20to=20BearerAuth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/server/main.go | 2 +- pkg/greet/api_v1.go | 4 ++-- pkg/greet/api_v2.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 963a622..87bbdd7 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -16,7 +16,7 @@ // @BasePath /api // @schemes http https // -// @securityDefinitions.apikey ApiKeyAuth +// @securityDefinitions.apikey BearerAuth // @in header // @name Authorization // @description JWT authentication using Bearer token. Format: Bearer diff --git a/pkg/greet/api_v1.go b/pkg/greet/api_v1.go index 7a65f84..82f2e6b 100644 --- a/pkg/greet/api_v1.go +++ b/pkg/greet/api_v1.go @@ -88,7 +88,7 @@ func (h *apiV1GreetHandler) RegisterRoutes(router chi.Router) { // @Accept json // @Produce json // @Success 200 {object} GreetResponse "Successful response" -// @Security ApiKeyAuth +// @Security BearerAuth // @Router /v1/greet [get] func (h *apiV1GreetHandler) handleGreetQuery(w http.ResponseWriter, r *http.Request) { name := r.URL.Query().Get("name") @@ -105,7 +105,7 @@ func (h *apiV1GreetHandler) handleGreetQuery(w http.ResponseWriter, r *http.Requ // @Param name path string true "Name to greet" // @Success 200 {object} GreetResponse "Successful response" // @Failure 400 {object} ErrorResponse "Invalid name parameter" -// @Security ApiKeyAuth +// @Security BearerAuth // @Router /v1/greet/{name} [get] func (h *apiV1GreetHandler) handleGreetPath(w http.ResponseWriter, r *http.Request) { name := chi.URLParam(r, "name") diff --git a/pkg/greet/api_v2.go b/pkg/greet/api_v2.go index 5378546..76fbc7c 100644 --- a/pkg/greet/api_v2.go +++ b/pkg/greet/api_v2.go @@ -55,7 +55,7 @@ type greetResponse struct { // @Param request body GreetRequest true "Greeting request" // @Success 200 {object} GreetResponseV2 "Successful response" // @Failure 400 {object} ValidationError "Validation error" -// @Security ApiKeyAuth +// @Security BearerAuth // @Router /v2/greet [post] func (h *apiV2GreetHandler) handleGreetPost(w http.ResponseWriter, r *http.Request) { // Read request body