优化GET类请求文档生成
This commit is contained in:
@ -45,6 +45,11 @@ func Test_parser_Openapi3(t *testing.T) {
|
||||
Name string `json:"name" d:"zhang" desc:"用户姓名" binding:"required"`
|
||||
Age string `json:"age" d:"18" desc:"年龄" binding:"required,oneof=12 13 18 90"`
|
||||
}
|
||||
type UserHead struct {
|
||||
Meta `json:"-" deprecated:"false" path:"/user/detail/head/{put_user_id}" method:"HEAD" desc:"测试接口" tag:"用户,搜索" content_type:"application/json" output_content_type:"application/json"`
|
||||
Name string `json:"name" d:"zhang" desc:"用户姓名" binding:"required"`
|
||||
Age string `json:"age" d:"18" desc:"年龄" binding:"required,oneof=12 13 18 90"`
|
||||
}
|
||||
type List struct {
|
||||
Total int64 `json:"total" binding:"required"`
|
||||
UserList []User `json:"user_list"`
|
||||
@ -54,11 +59,18 @@ func Test_parser_Openapi3(t *testing.T) {
|
||||
var fd UserDelete
|
||||
var up UserPut
|
||||
var ug UserGet
|
||||
var uh UserHead
|
||||
g := NewOpenapiDoc(nil, []*define.ServerItem{
|
||||
&define.ServerItem{
|
||||
Url: "http://127.0.0.1/v1",
|
||||
Description: "v1接口",
|
||||
Variables: nil,
|
||||
Variables: map[string]*define.ServerItemVariable{
|
||||
"test": &define.ServerItemVariable{
|
||||
Default: "123456",
|
||||
Description: "1111",
|
||||
Enum: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
&define.ServerItem{
|
||||
Url: "http://127.0.0.1/v2",
|
||||
@ -70,6 +82,7 @@ func Test_parser_Openapi3(t *testing.T) {
|
||||
g.AddApiFromInAndOut(reflect.TypeOf(fd), reflect.TypeOf(o))
|
||||
g.AddApiFromInAndOut(reflect.TypeOf(up), reflect.TypeOf(o))
|
||||
g.AddApiFromInAndOut(reflect.TypeOf(ug), reflect.TypeOf(o))
|
||||
g.AddApiFromInAndOut(reflect.TypeOf(uh), reflect.TypeOf(o))
|
||||
byteData, _ := json.Marshal(g.docData)
|
||||
fmt.Println(string(byteData))
|
||||
}
|
||||
|
Reference in New Issue
Block a user