mirror of
https://github.com/nprasad2077/NBA_Go.git
synced 2026-09-22 05:55:13 +00:00
swagger fixed
This commit is contained in:
@@ -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 API‑key 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
@@ -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
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
// @title NBA_Go API
|
||||
// @version 1.0
|
||||
// @description Stats service with API-key auth
|
||||
// @schemes http https
|
||||
// @BasePath /
|
||||
//
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name X-API-Key
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -13,7 +22,7 @@ import (
|
||||
"github.com/gofiber/fiber/v2/middleware/adaptor"
|
||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||
"github.com/nprasad2077/NBA_Go/config"
|
||||
"github.com/nprasad2077/NBA_Go/services"
|
||||
// "github.com/nprasad2077/NBA_Go/services"
|
||||
"github.com/nprasad2077/NBA_Go/controllers"
|
||||
"github.com/nprasad2077/NBA_Go/routes"
|
||||
"github.com/nprasad2077/NBA_Go/utils/middleware"
|
||||
@@ -58,29 +67,29 @@ func main() {
|
||||
routes.RegisterPlayerTotalRoutes(app, db)
|
||||
|
||||
/* ---------- Optional import job ---------- */
|
||||
go func() {
|
||||
for season := 2023; season <= 2025; season++ {
|
||||
if err := services.FetchAndStorePlayerAdvancedStats(db, season); err != nil {
|
||||
log.Printf("Fetch failed for player advanced season %d: %v\n", season, err)
|
||||
} else {
|
||||
log.Printf("Fetch successful for player advanced season %d\n", season)
|
||||
}
|
||||
time.Sleep(1100 * time.Millisecond) // optional delay
|
||||
}
|
||||
log.Printf("player advanced Import Success")
|
||||
}()
|
||||
// go func() {
|
||||
// for season := 2023; season <= 2025; season++ {
|
||||
// if err := services.FetchAndStorePlayerAdvancedStats(db, season); err != nil {
|
||||
// log.Printf("Fetch failed for player advanced season %d: %v\n", season, err)
|
||||
// } else {
|
||||
// log.Printf("Fetch successful for player advanced season %d\n", season)
|
||||
// }
|
||||
// time.Sleep(1100 * time.Millisecond) // optional delay
|
||||
// }
|
||||
// log.Printf("player advanced Import Success")
|
||||
// }()
|
||||
|
||||
go func() {
|
||||
for season := 2023; season <= 2025; season++ {
|
||||
if err := services.FetchAndStorePlayerTotalStats(db, season); err != nil {
|
||||
log.Printf("Fetch failed for player totals season %d: %v\n", season, err)
|
||||
} else {
|
||||
log.Printf("Fetch successful for player totals season %d\n", season)
|
||||
}
|
||||
time.Sleep(1000 * time.Millisecond) // optional delay
|
||||
}
|
||||
log.Printf("player totals Import Success")
|
||||
}()
|
||||
// go func() {
|
||||
// for season := 2023; season <= 2025; season++ {
|
||||
// if err := services.FetchAndStorePlayerTotalStats(db, season); err != nil {
|
||||
// log.Printf("Fetch failed for player totals season %d: %v\n", season, err)
|
||||
// } else {
|
||||
// log.Printf("Fetch successful for player totals season %d\n", season)
|
||||
// }
|
||||
// time.Sleep(1000 * time.Millisecond) // optional delay
|
||||
// }
|
||||
// log.Printf("player totals Import Success")
|
||||
// }()
|
||||
|
||||
/* ---------- START & SHUTDOWN ---------- */
|
||||
go func() {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Package main holds the global Swagger annotations.
|
||||
// Run “swag init --parseDependency --parseInternal” after editing.
|
||||
package main
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// General API information
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// @title NBA_Go API
|
||||
// @version 1.0
|
||||
// @description Stats service with API‑key auth
|
||||
// @schemes http https
|
||||
// @BasePath /
|
||||
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
// 🔐 SECURITY
|
||||
// -----------------------------------------------------------------------------
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name X-API-Key
|
||||
//
|
||||
// (each protected handler still needs `@Security ApiKeyAuth`)
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -0,0 +1,23 @@
|
||||
// swagger/swagger_doc.go
|
||||
package main
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Global Swagger metadata
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// @title NBA_Go API
|
||||
// @version 1.0
|
||||
// @description Stats service with API‑key auth
|
||||
// @schemes http https
|
||||
// @BasePath /
|
||||
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
// 🔐 SECURITY
|
||||
// -----------------------------------------------------------------------------
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name X-API-Key
|
||||
//
|
||||
// (each protected handler should still add `@Security ApiKeyAuth`)
|
||||
// -----------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user