docs(swagger): Move security annotations

This commit is contained in:
Nicolai Ort 2024-12-12 16:33:10 +01:00
parent 649ac2a3c2
commit 69f4de6739
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
7 changed files with 44 additions and 18 deletions

View File

@ -27,7 +27,7 @@ const docTemplate = `{
"get": {
"description": "Generate barcodes based on the provided data",
"produces": [
"application/pdf"
"image/png"
],
"tags": [
"barcodes"
@ -59,6 +59,11 @@ const docTemplate = `{
},
"/v1/pdfs/cards": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Generate cards based on the provided data",
"consumes": [
"application/json"
@ -86,6 +91,11 @@ const docTemplate = `{
},
"/v1/pdfs/certificates": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Generate certificates based on the provided data",
"consumes": [
"application/json"
@ -113,6 +123,11 @@ const docTemplate = `{
},
"/v1/pdfs/contracts": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Generate a contract based on the provided data",
"consumes": [
"application/json"
@ -369,12 +384,7 @@ const docTemplate = `{
"name": "key",
"in": "query"
}
},
"security": [
{
"ApiKeyAuth": []
}
]
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it

View File

@ -18,7 +18,7 @@
"get": {
"description": "Generate barcodes based on the provided data",
"produces": [
"application/pdf"
"image/png"
],
"tags": [
"barcodes"
@ -50,6 +50,11 @@
},
"/v1/pdfs/cards": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Generate cards based on the provided data",
"consumes": [
"application/json"
@ -77,6 +82,11 @@
},
"/v1/pdfs/certificates": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Generate certificates based on the provided data",
"consumes": [
"application/json"
@ -104,6 +114,11 @@
},
"/v1/pdfs/contracts": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Generate a contract based on the provided data",
"consumes": [
"application/json"
@ -360,10 +375,5 @@
"name": "key",
"in": "query"
}
},
"security": [
{
"ApiKeyAuth": []
}
]
}

View File

@ -182,7 +182,7 @@ paths:
required: true
type: string
produces:
- application/pdf
- image/png
responses: {}
summary: Generate barcodes
tags:
@ -202,6 +202,8 @@ paths:
produces:
- application/pdf
responses: {}
security:
- ApiKeyAuth: []
summary: Generate runner cards
tags:
- pdfs
@ -220,6 +222,8 @@ paths:
produces:
- application/pdf
responses: {}
security:
- ApiKeyAuth: []
summary: Generate runner certificates
tags:
- pdfs
@ -238,11 +242,11 @@ paths:
produces:
- application/pdf
responses: {}
security:
- ApiKeyAuth: []
summary: Generate a contract
tags:
- pdfs
security:
- ApiKeyAuth: []
securityDefinitions:
ApiKeyAuth:
in: query

View File

@ -16,6 +16,7 @@ import (
// @Accept json
// @Param data body models.CardRequest true "Card data"
// @Produce application/pdf
// @Security ApiKeyAuth
// @Router /v1/pdfs/cards [post]
func (h *DefaultHandler) GenerateCard(c *fiber.Ctx) error {
cardRequest := new(models.CardRequest)

View File

@ -16,6 +16,7 @@ import (
// @Accept json
// @Param data body models.CertificateRequest true "Certificate data"
// @Produce application/pdf
// @Security ApiKeyAuth
// @Router /v1/pdfs/certificates [post]
func (h *DefaultHandler) GenerateCertificate(c *fiber.Ctx) error {
certificateRequest := new(models.CertificateRequest)

View File

@ -16,6 +16,7 @@ import (
// @Accept json
// @Param data body models.ContractRequest true "Contract data"
// @Produce application/pdf
// @Security ApiKeyAuth
// @Router /v1/pdfs/contracts [post]
func (h *DefaultHandler) GenerateContract(c *fiber.Ctx) error {
contract := new(models.ContractRequest)

View File

@ -86,7 +86,6 @@ func main() {
v1 := app.Group("/v1")
// @Security ApiKeyAuth
pdfv1 := v1.Group("/pdfs")
pdfv1.Use(keyauth.New(keyauth.Config{
KeyLookup: "query:key",