Skip to content

Commit

Permalink
fix: setup swagger route using default echo to not brake swagger file…
Browse files Browse the repository at this point in the history
… generation
  • Loading branch information
diegoclair committed Oct 9, 2024
1 parent e704af9 commit aa394a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions transport/rest/routes/swaggerroute/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ package swaggerroute
import (
_ "github.com/diegoclair/go_boilerplate/docs"
"github.com/diegoclair/go_boilerplate/transport/rest/routeutils"
"github.com/labstack/echo/v4"
echoSwagger "github.com/swaggo/echo-swagger"
)

type swaggerRouter struct {
e *echo.Echo
}

func NewRouter() *swaggerRouter {
return &swaggerRouter{}
func NewRouter(e *echo.Echo) *swaggerRouter {
return &swaggerRouter{e: e}
}

// TODO: this route should not be public, only internal (maybe staging or dev environments)
func (r *swaggerRouter) RegisterRoutes(g *routeutils.EchoGroups) {
router := g.AppGroup.Group("swagger")
router := r.e.Group("swagger")
router.GET("/*", echoSwagger.WrapHandler)
}
2 changes: 1 addition & 1 deletion transport/rest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func NewRestServer(services *service.Apps, authToken infraContract.AuthToken, ca
authRoute := authroute.NewRouter(authHandler)
transferRoute := transferroute.NewRouter(transferHandler)

swaggerRoute := swaggerroute.NewRouter()
swaggerRoute := swaggerroute.NewRouter(router.Echo())

server := &Server{Router: router, cache: cache}
server.addRouters(accountRoute)
Expand Down

0 comments on commit aa394a3

Please sign in to comment.