Added swagger themes
This commit is contained in:
parent
b6e8d037a0
commit
0ff1188c3d
@ -62,7 +62,8 @@ func (r *Router) Init(e *gin.Engine) {
|
||||
{
|
||||
docs.GET("/swagger", ginext.RedirectTemporary("/documentation/swagger/"))
|
||||
docs.GET("/swagger/", ginresp.Wrap(swagger.Handle))
|
||||
docs.GET("/swagger/:fn", ginresp.Wrap(swagger.Handle))
|
||||
docs.GET("/swagger/:fn1", ginresp.Wrap(swagger.Handle))
|
||||
docs.GET("/swagger/:fn1/:fn2", ginresp.Wrap(swagger.Handle))
|
||||
}
|
||||
|
||||
// ================ Website ================
|
||||
|
@ -5,6 +5,13 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>API Documentation</title>
|
||||
<link rel="stylesheet" href="swagger-ui.css" />
|
||||
<!-- <link rel="stylesheet" href="themes/theme-feeling-blue.css" /> -->
|
||||
<!-- <link rel="stylesheet" href="themes/theme-flattop.css" /> -->
|
||||
<!-- <link rel="stylesheet" href="themes/theme-material.css" /> -->
|
||||
<!-- <link rel="stylesheet" href="themes/theme-monokai.css" /> -->
|
||||
<!-- <link rel="stylesheet" href="themes/theme-muted.css" /> -->
|
||||
<!-- <link rel="stylesheet" href="themes/theme-newspaper.css" /> -->
|
||||
<!-- <link rel="stylesheet" href="themes/theme-outline.css" /> -->
|
||||
</head>
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
@ -19,7 +26,8 @@
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
layout: "StandaloneLayout",
|
||||
defaultModelsExpandDepth: 0,
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
@ -9,12 +9,12 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed index.html
|
||||
//go:embed swagger.json
|
||||
//go:embed swagger.yaml
|
||||
//go:embed swagger-ui-bundle.js
|
||||
//go:embed swagger-ui.css
|
||||
//go:embed swagger-ui-standalone-preset.js
|
||||
//go:embed *.html
|
||||
//go:embed *.json
|
||||
//go:embed *.yaml
|
||||
//go:embed *.js
|
||||
//go:embed *.css
|
||||
//go:embed themes/*
|
||||
var assets embed.FS
|
||||
|
||||
func getAsset(fn string) ([]byte, string, bool) {
|
||||
@ -47,7 +47,8 @@ func getAsset(fn string) ([]byte, string, bool) {
|
||||
|
||||
func Handle(g *gin.Context) ginresp.HTTPResponse {
|
||||
type uri struct {
|
||||
Filename string `uri:"fn"`
|
||||
Filename1 string `uri:"fn1"`
|
||||
Filename2 *string `uri:"fn2"`
|
||||
}
|
||||
|
||||
var u uri
|
||||
@ -55,14 +56,19 @@ func Handle(g *gin.Context) ginresp.HTTPResponse {
|
||||
return ginresp.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
}
|
||||
|
||||
if u.Filename == "" {
|
||||
filename := u.Filename1
|
||||
if u.Filename2 != nil {
|
||||
filename = filename + "/" + *u.Filename2
|
||||
}
|
||||
|
||||
if filename == "" {
|
||||
index, _, _ := getAsset("index.html")
|
||||
return ginresp.Data(http.StatusOK, "text/html", index)
|
||||
}
|
||||
|
||||
if data, mime, ok := getAsset(u.Filename); ok {
|
||||
if data, mime, ok := getAsset(filename); ok {
|
||||
return ginresp.Data(http.StatusOK, mime, data)
|
||||
}
|
||||
|
||||
return ginresp.JSON(http.StatusNotFound, gin.H{"error": "AssetNotFound", "filename": u.Filename})
|
||||
return ginresp.JSON(http.StatusNotFound, gin.H{"error": "AssetNotFound", "filename": filename, "filename1": u.Filename1, "filename2": u.Filename2})
|
||||
}
|
||||
|
1672
server/swagger/themes/theme-feeling-blue.css
Normal file
1672
server/swagger/themes/theme-feeling-blue.css
Normal file
File diff suppressed because it is too large
Load Diff
1672
server/swagger/themes/theme-flattop.css
Normal file
1672
server/swagger/themes/theme-flattop.css
Normal file
File diff suppressed because it is too large
Load Diff
1719
server/swagger/themes/theme-material.css
Normal file
1719
server/swagger/themes/theme-material.css
Normal file
File diff suppressed because it is too large
Load Diff
1792
server/swagger/themes/theme-monokai.css
Normal file
1792
server/swagger/themes/theme-monokai.css
Normal file
File diff suppressed because it is too large
Load Diff
1673
server/swagger/themes/theme-muted.css
Normal file
1673
server/swagger/themes/theme-muted.css
Normal file
File diff suppressed because it is too large
Load Diff
1671
server/swagger/themes/theme-newspaper.css
Normal file
1671
server/swagger/themes/theme-newspaper.css
Normal file
File diff suppressed because it is too large
Load Diff
1652
server/swagger/themes/theme-outline.css
Normal file
1652
server/swagger/themes/theme-outline.css
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user