From f150030eeea2021cc47c4104bd2c6d7b26838a15 Mon Sep 17 00:00:00 2001 From: renaldybrada Date: Wed, 18 Feb 2026 10:28:16 +0700 Subject: [PATCH] swagger doc add bearer auth --- cmd/api/main.go | 6 ++++++ docs/docs.go | 14 +++++++++++++- docs/swagger.json | 14 +++++++++++++- docs/swagger.yaml | 7 +++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index 82a2f21..ce353e7 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -40,6 +40,12 @@ func gracefulShutdown(apiServer *http.Server, done chan bool) { // @description Dokumentasi API Antrian Operasi // @host localhost:8080 // @BasePath /api + +// @securityDefinitions.apikey BearerAuth +// @in header +// @name Authorization + +// @security BearerAuth func main() { log.Println("Starting API Service...") diff --git a/docs/docs.go b/docs/docs.go index 3bf7363..4073d99 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1390,7 +1390,19 @@ const docTemplate = `{ } } } - } + }, + "securityDefinitions": { + "BearerAuth": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + }, + "security": [ + { + "BearerAuth": [] + } + ] }` // SwaggerInfo holds exported Swagger Info so clients can modify it diff --git a/docs/swagger.json b/docs/swagger.json index 9fe502b..8359078 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1384,5 +1384,17 @@ } } } - } + }, + "securityDefinitions": { + "BearerAuth": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + }, + "security": [ + { + "BearerAuth": [] + } + ] } \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 7d89aa1..eb33486 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -908,4 +908,11 @@ paths: summary: Get List Tindakan tags: - Reference +security: +- BearerAuth: [] +securityDefinitions: + BearerAuth: + in: header + name: Authorization + type: apiKey swagger: "2.0"