优化schema生成

This commit is contained in:
2025-02-09 15:00:25 +08:00
parent 27f2ccf2aa
commit e4e8702fd4
3 changed files with 121 additions and 29 deletions

View File

@ -8,12 +8,10 @@
package api_doc
import (
"encoding/json"
"fmt"
"git.zhangdeman.cn/gateway/api-doc/define"
"git.zhangdeman.cn/zhangdeman/serialize"
"os"
"os/user"
"net/http"
"reflect"
"testing"
)
@ -31,17 +29,19 @@ func Test_parser_Openapi3(t *testing.T) {
List []A `json:"list"`
}
var bArr []*B
g := Generate{}
g := NewOpenapiDoc()
g.AddApiFromInAndOut(&define.UriBaseConfig{
Uri: "/a/b/c/d",
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(bArr), reflect.TypeOf(bArr))
fmt.Println(g.parseSliceItem(reflect.TypeOf(bArr)))
current, _ := user.Current()
byteData, _ := os.ReadFile(current.HomeDir + "/Downloads/test-openapi-doc.json")
var data define.OpenapiDoc
err := json.Unmarshal(byteData, &data)
if nil != err {
fmt.Println("解析失败 : " + err.Error())
} else {
fmt.Println("解析成功")
}
}
func TestParseForSwagger(t *testing.T) {