fix: 升级适配api-doc
This commit is contained in:
@ -15,8 +15,42 @@ import (
|
||||
)
|
||||
|
||||
func NewDoc(info *define.Info, servers []*define.ServerItem) *Doc {
|
||||
if nil == info {
|
||||
info = &define.Info{
|
||||
Description: "",
|
||||
Title: "",
|
||||
TermsOfService: "",
|
||||
Contact: &define.Contact{
|
||||
Name: "",
|
||||
Url: "",
|
||||
Email: "",
|
||||
},
|
||||
License: nil,
|
||||
Version: "",
|
||||
}
|
||||
}
|
||||
if nil == info.Contact {
|
||||
info.Contact = &define.Contact{
|
||||
Name: "",
|
||||
Url: "",
|
||||
Email: "",
|
||||
}
|
||||
}
|
||||
if nil == info.License {
|
||||
info.License = &define.License{
|
||||
Name: "",
|
||||
Url: "",
|
||||
}
|
||||
}
|
||||
return &Doc{
|
||||
instance: apiDoc.NewOpenapiDoc(info, servers),
|
||||
instance: apiDoc.NewOpenapiDoc(
|
||||
apiDoc.WithDocDescription(info.Description),
|
||||
apiDoc.WithDocTitle(info.Title),
|
||||
apiDoc.WithDocContactEmail(info.Contact.Email),
|
||||
apiDoc.WithDocContactName(info.Contact.Name),
|
||||
apiDoc.WithDocLicense(info.License.Name),
|
||||
apiDoc.WithDocServers(servers),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,13 @@ import (
|
||||
"github.com/gin-contrib/pprof"
|
||||
|
||||
apiDocDefine "git.zhangdeman.cn/zhangdeman/api-doc/define"
|
||||
apiDocEnum "git.zhangdeman.cn/zhangdeman/api-doc/enums"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func newServerOption(port int, optionList ...SetServerOptionFunc) *serverOption {
|
||||
option := &serverOption{
|
||||
swaggerUiTheme: apiDocDefine.SwaggerUIThemeRedocFree,
|
||||
swaggerUiTheme: apiDocEnum.SwaggerUIThemeRedocFree.String(),
|
||||
swaggerBaseUri: "/doc/swagger",
|
||||
globalMiddlewareList: nil,
|
||||
disableSwaggerDoc: false,
|
||||
@ -125,7 +126,7 @@ func NewServer(port int, optionList ...SetServerOptionFunc) *server {
|
||||
}
|
||||
return &server{
|
||||
router: r,
|
||||
uiInstance: apiDoc.NewSwaggerUI(option.serverInfo, option.serverList, option.swaggerUiTheme),
|
||||
uiInstance: apiDoc.NewSwaggerUI(option.serverInfo, option.serverList, apiDocEnum.SwaggerUITheme(option.swaggerUiTheme)),
|
||||
port: port,
|
||||
option: option,
|
||||
}
|
||||
|
@ -8,8 +8,9 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func TestNewServer(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user