42 lines
929 B
Go
42 lines
929 B
Go
// Package api_doc ...
|
|
//
|
|
// Description : api_doc ...
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2024-07-19 17:52
|
|
package api_doc
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"git.zhangdeman.cn/gateway/api-doc/define"
|
|
"git.zhangdeman.cn/zhangdeman/serialize"
|
|
"os"
|
|
"os/user"
|
|
"testing"
|
|
)
|
|
|
|
// Test_parser_Openapi3 测试数据结构定义正确性
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 17:55 2024/7/19
|
|
func Test_parser_Openapi3(t *testing.T) {
|
|
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) {
|
|
docUrl := "https://git.zhangdeman.cn/swagger.v1.json"
|
|
res, _ := Parse(docUrl)
|
|
serialize.JSON.ConsoleOutput(res)
|
|
}
|