优化接口基础信息解析 + 支持设置接口是否弃用
This commit is contained in:
@ -10,13 +10,14 @@ package api_doc
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.zhangdeman.cn/gateway/api-doc/define"
|
||||
"git.zhangdeman.cn/zhangdeman/serialize"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type Meta struct {
|
||||
}
|
||||
|
||||
// Test_parser_Openapi3 测试数据结构定义正确性
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
@ -24,6 +25,7 @@ import (
|
||||
// Date : 17:55 2024/7/19
|
||||
func Test_parser_Openapi3(t *testing.T) {
|
||||
type User struct {
|
||||
Meta `json:"-" deprecated:"true" path:"/user/detail" method:"POST" 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"`
|
||||
}
|
||||
@ -31,22 +33,13 @@ func Test_parser_Openapi3(t *testing.T) {
|
||||
Total int64 `json:"total" binding:"required"`
|
||||
UserList []User `json:"user_list"`
|
||||
}
|
||||
var l List
|
||||
var o List
|
||||
var f User
|
||||
g := NewOpenapiDoc(nil, nil)
|
||||
g.AddApiFromInAndOut(&define.UriBaseConfig{
|
||||
Uri: "/ent/user/detail",
|
||||
Method: http.MethodPost,
|
||||
ContentType: []string{"application/x-www-form-urlencoded"},
|
||||
OutputContentType: []string{"application/yml", "application/json", "application/xml"},
|
||||
TagList: []string{"测试文档生成"},
|
||||
Summary: "测试接口",
|
||||
Description: "",
|
||||
ParamList: nil,
|
||||
ResultList: nil,
|
||||
}, reflect.TypeOf(l), reflect.TypeOf(l))
|
||||
g.AddApiFromInAndOut(reflect.TypeOf(f), reflect.TypeOf(o))
|
||||
byteData, _ := json.Marshal(g.docData)
|
||||
fmt.Println(string(byteData))
|
||||
fmt.Println(g.parseSliceItem("", reflect.TypeOf(l)))
|
||||
fmt.Println(g.parseSliceItem("", reflect.TypeOf(o)))
|
||||
}
|
||||
|
||||
func TestParseForSwagger(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user