v1基础请求参数构建
This commit is contained in:
63
swagger/run_test.go
Normal file
63
swagger/run_test.go
Normal file
@ -0,0 +1,63 @@
|
||||
// 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))
|
||||
}
|
Reference in New Issue
Block a user