From 1dfd96869dac822501909aa13a5b4479adbb2e17 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 11 Dec 2024 19:39:18 +0100 Subject: [PATCH] docs(swagger): Swagger auth --- docs/docs.go | 14 +++++++++++++- docs/swagger.json | 14 +++++++++++++- docs/swagger.yaml | 7 +++++++ main.go | 4 ++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 27e8d8d..6478a07 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -320,7 +320,19 @@ const docTemplate = `{ } } } - } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "key", + "in": "query" + } + }, + "security": [ + { + "ApiKeyAuth": [] + } + ] }` // SwaggerInfo holds exported Swagger Info so clients can modify it diff --git a/docs/swagger.json b/docs/swagger.json index ee74d8d..8f5167d 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -311,5 +311,17 @@ } } } - } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "key", + "in": "query" + } + }, + "security": [ + { + "ApiKeyAuth": [] + } + ] } \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a2ad25c..89b3374 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -211,4 +211,11 @@ paths: summary: Generate a contract tags: - contracts +security: +- ApiKeyAuth: [] +securityDefinitions: + ApiKeyAuth: + in: query + name: key + type: apiKey swagger: "2.0" diff --git a/main.go b/main.go index 0fbfed5..26611ca 100644 --- a/main.go +++ b/main.go @@ -57,6 +57,9 @@ func loadEnv() error { // @title LfK Document Server API // @description This is the API documentation for the LfK Document Server - a tool for pdf generation. +// @securityDefinitions.apiKey ApiKeyAuth +// @in query +// @name key func main() { err := loadEnv() @@ -76,6 +79,7 @@ func main() { // Swagger documentation route app.Get("/swagger/*", swagger.HandlerDefault) + // @Security ApiKeyAuth v1 := app.Group("/v1") v1.Use(keyauth.New(keyauth.Config{ KeyLookup: "query:key",