Skip to content

Commit

Permalink
fix: Serve ReDoc JS from Argo CD server instead of from CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
jannfis committed Oct 16, 2020
1 parent e09cacb commit 9c03ef7
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
110 changes: 110 additions & 0 deletions ui/src/assets/scripts/redoc.standalone.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions util/swagger/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"github.com/go-openapi/runtime/middleware"
)

// filename of ReDoc script in UI's assets/scripts path
const redocScriptName = "redoc.standalone.js"

// ServeSwaggerUI serves the Swagger UI and JSON spec.
func ServeSwaggerUI(mux *http.ServeMux, swaggerJSON string, uiPath string, rootPath string) {
prefix := path.Dir(uiPath)
Expand All @@ -17,9 +20,11 @@ func ServeSwaggerUI(mux *http.ServeMux, swaggerJSON string, uiPath string, rootP
})

specURL := path.Join(prefix, rootPath, "swagger.json")
scriptURL := path.Join(prefix, rootPath, "assets", "scripts", redocScriptName)
mux.Handle(uiPath, middleware.Redoc(middleware.RedocOpts{
BasePath: prefix,
SpecURL: specURL,
Path: path.Base(uiPath),
RedocURL: scriptURL,
}, http.NotFoundHandler()))
}

0 comments on commit 9c03ef7

Please sign in to comment.