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 // GetAllAdvancedPlayerStats godoc
// @Security ApiKeyAuth // //@Security ApiKeyAuth
// @Summary Get player advanced stats // @Summary Get player advanced stats
// @Description Returns filtered and paginated player advanced stats // @Description Returns filtered and paginated player advanced stats
// @Tags PlayerStats // @Tags PlayerStats
+1 -1
View File
@@ -67,7 +67,7 @@ func ScrapePlayerShotChart(db *gorm.DB) fiber.Handler {
} }
// GetPlayerShotChart godoc // GetPlayerShotChart godoc
// @Security ApiKeyAuth // //@Security ApiKeyAuth
// @Summary Get shot-chart data // @Summary Get shot-chart data
// @Description Returns shot-chart points, optionally filtered by playerId and/or season // @Description Returns shot-chart points, optionally filtered by playerId and/or season
// @Tags PlayerShotChart // @Tags PlayerShotChart
+1 -1
View File
@@ -57,7 +57,7 @@ func ScrapePlayerTotalStats(db *gorm.DB) fiber.Handler {
} }
// GetPlayerTotalStats godoc // GetPlayerTotalStats godoc
// @Security ApiKeyAuth // //@Security ApiKeyAuth
// @Summary Get player total stats // @Summary Get player total stats
// @Description Filter and paginate player totals // @Description Filter and paginate player totals
// @Tags PlayerTotals // @Tags PlayerTotals
+1 -1
View File
@@ -24,7 +24,7 @@ services:
db-init: db-init:
build: . build: .
env_file: .env env_file: .env
command: ["/nba_go", "import-data"] command: ["/nba_go"]
depends_on: depends_on:
postgres: postgres:
condition: service_healthy condition: service_healthy
+1 -23
View File
@@ -17,11 +17,6 @@ const docTemplate = `{
"paths": { "paths": {
"/api/playeradvancedstats": { "/api/playeradvancedstats": {
"get": { "get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Returns filtered and paginated player advanced stats", "description": "Returns filtered and paginated player advanced stats",
"consumes": [ "consumes": [
"application/json" "application/json"
@@ -160,11 +155,6 @@ const docTemplate = `{
}, },
"/api/playershotchart": { "/api/playershotchart": {
"get": { "get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Returns shot-chart points, optionally filtered by playerId and/or season", "description": "Returns shot-chart points, optionally filtered by playerId and/or season",
"consumes": [ "consumes": [
"application/json" "application/json"
@@ -281,11 +271,6 @@ const docTemplate = `{
}, },
"/api/playertotals": { "/api/playertotals": {
"get": { "get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Filter and paginate player totals", "description": "Filter and paginate player totals",
"consumes": [ "consumes": [
"application/json" "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: "/", BasePath: "/",
Schemes: []string{"http", "https"}, Schemes: []string{"http", "https"},
Title: "NBA_Go API", Title: "NBA_Go API",
Description: "Stats service with API-key auth", Description: "Stats service, now with public access!",
InfoInstanceName: "swagger", InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate, SwaggerTemplate: docTemplate,
LeftDelim: "{{", LeftDelim: "{{",
+1 -23
View File
@@ -5,7 +5,7 @@
], ],
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "Stats service with API-key auth", "description": "Stats service, now with public access!",
"title": "NBA_Go API", "title": "NBA_Go API",
"contact": {}, "contact": {},
"version": "1.0" "version": "1.0"
@@ -14,11 +14,6 @@
"paths": { "paths": {
"/api/playeradvancedstats": { "/api/playeradvancedstats": {
"get": { "get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Returns filtered and paginated player advanced stats", "description": "Returns filtered and paginated player advanced stats",
"consumes": [ "consumes": [
"application/json" "application/json"
@@ -157,11 +152,6 @@
}, },
"/api/playershotchart": { "/api/playershotchart": {
"get": { "get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Returns shot-chart points, optionally filtered by playerId and/or season", "description": "Returns shot-chart points, optionally filtered by playerId and/or season",
"consumes": [ "consumes": [
"application/json" "application/json"
@@ -278,11 +268,6 @@
}, },
"/api/playertotals": { "/api/playertotals": {
"get": { "get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Filter and paginate player totals", "description": "Filter and paginate player totals",
"consumes": [ "consumes": [
"application/json" "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 type: object
info: info:
contact: {} contact: {}
description: Stats service with API-key auth description: Stats service, now with public access!
title: NBA_Go API title: NBA_Go API
version: "1.0" version: "1.0"
paths: paths:
@@ -182,8 +182,6 @@ paths:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
security:
- ApiKeyAuth: []
summary: Get player advanced stats summary: Get player advanced stats
tags: tags:
- PlayerStats - PlayerStats
@@ -251,8 +249,6 @@ paths:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
security:
- ApiKeyAuth: []
summary: Get shot-chart data summary: Get shot-chart data
tags: tags:
- PlayerShotChart - PlayerShotChart
@@ -355,8 +351,6 @@ paths:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
security:
- ApiKeyAuth: []
summary: Get player total stats summary: Get player total stats
tags: tags:
- PlayerTotals - PlayerTotals
@@ -397,9 +391,4 @@ paths:
schemes: schemes:
- http - http
- https - https
securityDefinitions:
ApiKeyAuth:
in: header
name: X-API-Key
type: apiKey
swagger: "2.0" swagger: "2.0"
+11 -5
View File
@@ -1,12 +1,17 @@
// @title NBA_Go API // @title NBA_Go API
// @version 1.0 // @version 1.0
// @description Stats service with API-key auth // @description Stats service, now with public access!
// @schemes http https // @schemes http https
// @BasePath / // @BasePath /
// //
// @securityDefinitions.apikey ApiKeyAuth // To re-enable security docs:
// @in header // 1. Uncomment the securityDefinitions block below.
// @name X-API-Key // 2. Uncomment the @Security annotation in each controller.
// 3. Run 'swag init'.
//
// //@securityDefinitions.apikey ApiKeyAuth
// //@in header
// //@name X-API-Key
package main package main
import ( import (
@@ -88,7 +93,8 @@ func main() {
controllers.RegisterKeyAdminRoutes(app, db) controllers.RegisterKeyAdminRoutes(app, db)
/* ---------- PROTECTED ROUTES ---------- */ /* ---------- 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.RegisterPlayerAdvancedRoutes(app, db)
routes.RegisterPlayerTotalRoutes(app, db) routes.RegisterPlayerTotalRoutes(app, db)
routes.RegisterPlayerShotChartRoutes(app, db) routes.RegisterPlayerShotChartRoutes(app, db)