Move SwaggerUI to /api/v3/swagger-ui

Include the `v3` path component in the Swagger UI URL.
This commit is contained in:
Sybren A. Stüvel 2022-07-04 12:17:57 +02:00
parent 5537f2c07c
commit 7d64d1bca4
5 changed files with 7 additions and 5 deletions

View File

@ -105,7 +105,7 @@ project, which is unfortunate. However, this approach does have some advantages:
## Swagger UI ## Swagger UI
Flamenco Manager has a SwaggerUI interface at http://localhost:8080/api/swagger-ui/ Flamenco Manager has a SwaggerUI interface at http://localhost:8080/api/v3/swagger-ui/
## SocketIO ## SocketIO

View File

@ -287,7 +287,7 @@ func buildWebService(
api.RegisterHandlers(e, flamenco) api.RegisterHandlers(e, flamenco)
webUpdater.RegisterHandlers(e) webUpdater.RegisterHandlers(e)
swagger_ui.RegisterSwaggerUIStaticFiles(e) swagger_ui.RegisterSwaggerUIStaticFiles(e)
e.GET("/api/openapi3.json", func(c echo.Context) error { e.GET("/api/v3/openapi3.json", func(c echo.Context) error {
return c.JSON(http.StatusOK, swagger) return c.JSON(http.StatusOK, swagger)
}) })

View File

@ -39,7 +39,7 @@
window.onload = function() { window.onload = function() {
// Begin Swagger UI call region // Begin Swagger UI call region
const ui = SwaggerUIBundle({ const ui = SwaggerUIBundle({
url: "/api/openapi3.json", url: "/api/v3/openapi3.json",
dom_id: '#swagger-ui', dom_id: '#swagger-ui',
deepLinking: true, deepLinking: true,
presets: [ presets: [

View File

@ -12,6 +12,8 @@ import (
//go:embed static //go:embed static
var swaggerUI embed.FS var swaggerUI embed.FS
const swaggerURL = "/api/v3/swagger-ui/"
func RegisterSwaggerUIStaticFiles(router *echo.Echo) { func RegisterSwaggerUIStaticFiles(router *echo.Echo) {
files, err := fs.Sub(swaggerUI, "static") files, err := fs.Sub(swaggerUI, "static")
if err != nil { if err != nil {
@ -19,5 +21,5 @@ func RegisterSwaggerUIStaticFiles(router *echo.Echo) {
} }
httpHandler := http.FileServer(http.FS(files)) httpHandler := http.FileServer(http.FS(files))
router.GET("/api/swagger-ui/*", echo.WrapHandler(http.StripPrefix("/api/swagger-ui/", httpHandler))) router.GET(swaggerURL+"*", echo.WrapHandler(http.StripPrefix(swaggerURL, httpHandler)))
} }

View File

@ -17,7 +17,7 @@
<api-spinner /> <api-spinner />
<span class="app-version"> <span class="app-version">
<a href="/flamenco3-addon.zip">addon</a> <a href="/flamenco3-addon.zip">addon</a>
| <a href="/api/swagger-ui/">API</a> | <a href="/api/v3/swagger-ui/">API</a>
| version: {{ flamencoVersion }} | version: {{ flamencoVersion }}
</span> </span>
</header> </header>