Files
PandaX/pkg/middleware/swagger.go
2022-08-03 17:21:07 +08:00

45 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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: "这是PandaX框架文档根据文档调用API",
Contact: &spec.ContactInfo{
ContactInfoProps: spec.ContactInfoProps{
Name: "PandaX 熊猫",
Email: "2417920382@qq.com",
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",
},
}
}