64 lines
1.5 KiB
Go
64 lines
1.5 KiB
Go
|
// Package swagger ...
|
||
|
//
|
||
|
// Description : swagger ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 2024-04-22 16:02
|
||
|
package swagger
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"git.zhangdeman.cn/gateway/api-doc/define"
|
||
|
"git.zhangdeman.cn/zhangdeman/consts"
|
||
|
"net/http"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestGenerate(t *testing.T) {
|
||
|
res, _ := Generate(&define.SwaggerInput{
|
||
|
Schemes: []string{},
|
||
|
Swagger: define.SwaggerVersion2,
|
||
|
Host: "http://www.baidu.com",
|
||
|
BasePath: "/",
|
||
|
Info: define.Info{
|
||
|
Description: "测试",
|
||
|
Title: "测试",
|
||
|
Contact: define.Contact{
|
||
|
Name: "白茶",
|
||
|
Url: "http://www.baidu.com",
|
||
|
Email: "go@email.com",
|
||
|
},
|
||
|
License: define.License{
|
||
|
Name: consts.LicenseApache20,
|
||
|
Url: consts.LicenseUrlTable[consts.LicenseApache20],
|
||
|
},
|
||
|
Version: "",
|
||
|
},
|
||
|
PathConfigList: []*define.SwaggerPathInput{
|
||
|
&define.SwaggerPathInput{
|
||
|
Uri: "/test",
|
||
|
Method: http.MethodPost,
|
||
|
ContentType: consts.MimeTypeJson,
|
||
|
Summary: "测试接口",
|
||
|
Description: "测试接口",
|
||
|
TagList: []string{"test"},
|
||
|
ParameterList: []*define.SwaggerParameterInput{
|
||
|
&define.SwaggerParameterInput{
|
||
|
Type: consts.DataTypeString,
|
||
|
Description: "姓名",
|
||
|
Name: "name",
|
||
|
In: "body",
|
||
|
Required: true,
|
||
|
EnumList: []interface{}{"zhang", "de", "man"},
|
||
|
},
|
||
|
},
|
||
|
ResponseList: nil,
|
||
|
},
|
||
|
},
|
||
|
})
|
||
|
byteData, _ := json.MarshalIndent(res, "", "\t")
|
||
|
fmt.Println(string(byteData))
|
||
|
}
|