swagger update

This commit is contained in:
Ravi Prasad
2025-06-18 22:32:08 -05:00
parent 0aac099136
commit 9475e1a245
8 changed files with 18 additions and 67 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ func ScrapePlayerAdvancedStats(db *gorm.DB) fiber.Handler {
}
// GetAllAdvancedPlayerStats godoc
// @Security ApiKeyAuth
// //@Security ApiKeyAuth
// @Summary Get player advanced stats
// @Description Returns filtered and paginated player advanced stats
// @Tags PlayerStats
+1 -1
View File
@@ -67,7 +67,7 @@ func ScrapePlayerShotChart(db *gorm.DB) fiber.Handler {
}
// GetPlayerShotChart godoc
// @Security ApiKeyAuth
// //@Security ApiKeyAuth
// @Summary Get shot-chart data
// @Description Returns shot-chart points, optionally filtered by playerId and/or season
// @Tags PlayerShotChart
+1 -1
View File
@@ -57,7 +57,7 @@ func ScrapePlayerTotalStats(db *gorm.DB) fiber.Handler {
}
// GetPlayerTotalStats godoc
// @Security ApiKeyAuth
// //@Security ApiKeyAuth
// @Summary Get player total stats
// @Description Filter and paginate player totals
// @Tags PlayerTotals
+1 -1
View File
@@ -24,7 +24,7 @@ services:
db-init:
build: .
env_file: .env
command: ["/nba_go", "import-data"]
command: ["/nba_go"]
depends_on:
postgres:
condition: service_healthy
+1 -23
View File
@@ -17,11 +17,6 @@ const docTemplate = `{
"paths": {
"/api/playeradvancedstats": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Returns filtered and paginated player advanced stats",
"consumes": [
"application/json"
@@ -160,11 +155,6 @@ const docTemplate = `{
},
"/api/playershotchart": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Returns shot-chart points, optionally filtered by playerId and/or season",
"consumes": [
"application/json"
@@ -281,11 +271,6 @@ const docTemplate = `{
},
"/api/playertotals": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Filter and paginate player totals",
"consumes": [
"application/json"
@@ -605,13 +590,6 @@ const docTemplate = `{
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "X-API-Key",
"in": "header"
}
}
}`
@@ -622,7 +600,7 @@ var SwaggerInfo = &swag.Spec{
BasePath: "/",
Schemes: []string{"http", "https"},
Title: "NBA_Go API",
Description: "Stats service with API-key auth",
Description: "Stats service, now with public access!",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
+1 -23
View File
@@ -5,7 +5,7 @@
],
"swagger": "2.0",
"info": {
"description": "Stats service with API-key auth",
"description": "Stats service, now with public access!",
"title": "NBA_Go API",
"contact": {},
"version": "1.0"
@@ -14,11 +14,6 @@
"paths": {
"/api/playeradvancedstats": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Returns filtered and paginated player advanced stats",
"consumes": [
"application/json"
@@ -157,11 +152,6 @@
},
"/api/playershotchart": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Returns shot-chart points, optionally filtered by playerId and/or season",
"consumes": [
"application/json"
@@ -278,11 +268,6 @@
},
"/api/playertotals": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Filter and paginate player totals",
"consumes": [
"application/json"
@@ -602,12 +587,5 @@
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "X-API-Key",
"in": "header"
}
}
}
+1 -12
View File
@@ -123,7 +123,7 @@ definitions:
type: object
info:
contact: {}
description: Stats service with API-key auth
description: Stats service, now with public access!
title: NBA_Go API
version: "1.0"
paths:
@@ -182,8 +182,6 @@ paths:
additionalProperties:
type: string
type: object
security:
- ApiKeyAuth: []
summary: Get player advanced stats
tags:
- PlayerStats
@@ -251,8 +249,6 @@ paths:
additionalProperties:
type: string
type: object
security:
- ApiKeyAuth: []
summary: Get shot-chart data
tags:
- PlayerShotChart
@@ -355,8 +351,6 @@ paths:
additionalProperties:
type: string
type: object
security:
- ApiKeyAuth: []
summary: Get player total stats
tags:
- PlayerTotals
@@ -397,9 +391,4 @@ paths:
schemes:
- http
- https
securityDefinitions:
ApiKeyAuth:
in: header
name: X-API-Key
type: apiKey
swagger: "2.0"
+11 -5
View File
@@ -1,12 +1,17 @@
// @title NBA_Go API
// @version 1.0
// @description Stats service with API-key auth
// @description Stats service, now with public access!
// @schemes http https
// @BasePath /
//
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name X-API-Key
// To re-enable security docs:
// 1. Uncomment the securityDefinitions block below.
// 2. Uncomment the @Security annotation in each controller.
// 3. Run 'swag init'.
//
// //@securityDefinitions.apikey ApiKeyAuth
// //@in header
// //@name X-API-Key
package main
import (
@@ -88,7 +93,8 @@ func main() {
controllers.RegisterKeyAdminRoutes(app, db)
/* ---------- PROTECTED ROUTES ---------- */
app.Use(middleware.APIKeyAuth(db))
// Remove Comment to re-enable api key middleware.
// app.Use(middleware.APIKeyAuth(db))
routes.RegisterPlayerAdvancedRoutes(app, db)
routes.RegisterPlayerTotalRoutes(app, db)
routes.RegisterPlayerShotChartRoutes(app, db)