【更新】更新restful

This commit is contained in:
PandaGoAdmin
2022-08-03 16:00:32 +08:00
parent 2cb23c0ecf
commit 6945277fdb
48 changed files with 1234 additions and 836 deletions

44
pkg/middleware/swagger.go Normal file
View File

@@ -0,0 +1,44 @@
package middleware
import (
restfulspec "github.com/emicklei/go-restful-openapi/v2"
"github.com/emicklei/go-restful/v3"
"github.com/go-openapi/spec"
)
/**
* @Description
* @Author 熊猫
* @Date 2022/8/3 9:16
**/
func SwaggerConfig(wsContainer *restful.Container) {
config := restfulspec.Config{
WebServices: wsContainer.RegisteredWebServices(),
APIPath: "/apidocs.json",
PostBuildSwaggerObjectHandler: enrichSwaggerObject}
wsContainer.Add(restfulspec.NewOpenAPIService(config))
}
func enrichSwaggerObject(swo *spec.Swagger) {
swo.Info = &spec.Info{
InfoProps: spec.InfoProps{
Title: "Pandax API",
Description: "Restful Api",
Contact: &spec.ContactInfo{
ContactInfoProps: spec.ContactInfoProps{
Name: "PandaX",
Email: "PandaX@doe.rp",
URL: "https://github.com/XM-GO/PandaX",
},
},
License: &spec.License{
LicenseProps: spec.LicenseProps{
Name: "MIT",
URL: "https://github.com/XM-GO/PandaX",
},
},
Version: "1.0.0",
},
}
}