File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,11 @@ import (
44 "net/http"
55
66 "github.com/gin-gonic/gin"
7+ "github.com/rs/zerolog/log"
78 "github.com/spf13/cobra"
89 swaggerFiles "github.com/swaggo/files"
910 ginSwagger "github.com/swaggo/gin-swagger"
11+ "github.com/swaggo/swag"
1012
1113 "github.com/thirdweb-dev/indexer/internal/handlers"
1214 "github.com/thirdweb-dev/indexer/internal/middleware"
@@ -46,7 +48,14 @@ func RunApi(cmd *cobra.Command, args []string) {
4648 r .GET ("/swagger/*any" , ginSwagger .WrapHandler (swaggerFiles .Handler ))
4749 // Add Swagger JSON endpoint
4850 r .GET ("/openapi.json" , func (c * gin.Context ) {
49- c .File ("./docs/swagger.json" )
51+ doc , err := swag .ReadDoc ()
52+ if err != nil {
53+ log .Error ().Err (err ).Msg ("Failed to read Swagger documentation" )
54+ c .JSON (http .StatusInternalServerError , gin.H {"error" : "Failed to provide Swagger documentation" })
55+ return
56+ }
57+ c .Header ("Content-Type" , "application/json" )
58+ c .String (http .StatusOK , doc )
5059 })
5160
5261 root := r .Group ("/:chainId" )
You can’t perform that action at this time.
0 commit comments