From 51c1ad657378a1953654062abb5ef21eb884ac24 Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Thu, 30 Apr 2026 22:49:51 +0300 Subject: [PATCH] feat: Add Swagger documentation endpoint and update API route prefix from /v1 to /api/v1 - Add swaggo/files and swaggo/gin-swagger imports for Swagger documentation - Change API route group prefix from "/v1" to "/api/v1" - Add GET /api/v1/swagger/*any endpoint for Swagger UI documentation - Update RBAC path from "/v1/users" to "/api/v1/users" for consistency --- apps/api-server/cmd/server_routes.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/api-server/cmd/server_routes.go b/apps/api-server/cmd/server_routes.go index 8f502e8..37b4c0b 100644 --- a/apps/api-server/cmd/server_routes.go +++ b/apps/api-server/cmd/server_routes.go @@ -2,6 +2,8 @@ package main import ( "github.com/gin-gonic/gin" + swaggerFiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" "github.com/nutcas3/telecom-platform/apps/api-server/internal/middleware" "github.com/nutcas3/telecom-platform/apps/api-server/internal/rbac" @@ -11,13 +13,16 @@ import ( // RBAC enforcement uses Casbin when configured, falling back to role-based // middleware otherwise. func registerV1Routes(router *gin.Engine, d *serverDeps) { - v1 := router.Group("/v1") + v1 := router.Group("/api/v1") // Health check v1.GET("/health", func(c *gin.Context) { c.JSON(200, gin.H{"status": "ok"}) }) + // Swagger documentation + v1.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) + // Charging engine integration (public for packet-gateway integration) charging := v1.Group("/charging") { @@ -46,7 +51,7 @@ func registerV1Routes(router *gin.Engine, d *serverDeps) { } users := protected.Group("/users") - applyRBAC(users, d.casbinSvc, "/v1/users", "GET", "admin") + applyRBAC(users, d.casbinSvc, "/api/v1/users", "GET", "admin") { users.GET("", d.authH.GetUsers) users.POST("", d.authH.CreateUser)