swagger fixed

This commit is contained in:
Ravi Prasad
2025-05-08 17:11:25 -05:00
parent 8c577b441c
commit 1d3edc68b4
8 changed files with 119 additions and 56 deletions
-27
View File
@@ -1,27 +0,0 @@
//go:build docs
// +build docs
// Package docs Only contains Swagger annotations that are **global**.
// Run `swag init --parseDependency --parseInternal` after editing.
package docs
// ------------------------------------------------------------
// General API meta (kept here so CI can inject version/build).
// ------------------------------------------------------------
// @title NBA_Go API
// @version 1.0
// @description Stats service with APIkey auth
// @BasePath /
// @schemes http https
// ------------------------------------------------------------
// 🔐 SECURITY this block is what you asked for
// ------------------------------------------------------------
//
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name X-API-Key
//
// (every protected endpoint still needs `@Security ApiKeyAuth`)
// ------------------------------------------------------------
+12 -5
View File
@@ -174,17 +174,24 @@ const docTemplate = `{
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "X-API-Key",
"in": "header"
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "",
Version: "1.0",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
BasePath: "/",
Schemes: []string{"http", "https"},
Title: "NBA_Go API",
Description: "Stats service with API-key auth",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
+16 -1
View File
@@ -1,8 +1,16 @@
{
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"contact": {}
"description": "Stats service with API-key auth",
"title": "NBA_Go API",
"contact": {},
"version": "1.0"
},
"basePath": "/",
"paths": {
"/api/playeradvancedstats": {
"get": {
@@ -163,5 +171,12 @@
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "X-API-Key",
"in": "header"
}
}
}
+12
View File
@@ -1,5 +1,9 @@
basePath: /
info:
contact: {}
description: Stats service with API-key auth
title: NBA_Go API
version: "1.0"
paths:
/api/playeradvancedstats:
get:
@@ -105,4 +109,12 @@ paths:
summary: Get player total stats
tags:
- PlayerTotals
schemes:
- http
- https
securityDefinitions:
ApiKeyAuth:
in: header
name: X-API-Key
type: apiKey
swagger: "2.0"