规划文档生成方法生成

This commit is contained in:
白茶清欢 2024-07-22 16:04:21 +08:00
parent 60796b6e4f
commit 967f211631
4 changed files with 63 additions and 7 deletions

View File

@ -263,12 +263,12 @@ type Response struct {
//
// Date : 16:10 2024/4/19
type Info struct {
Description string `json:"description"` // 对应用的简短描述。 CommonMark syntax 可以被用来表示富文本呈现。
Title string `json:"title" required:"true"` // 必选. 应用的名称。
TermsOfService string `json:"termsOfService"` // 指向服务条款的 URL 地址,必须是 URL 地址格式。
Contact Contact `json:"contact"` // 联系方式
License License `json:"license"` // 开源协议
Version string `json:"version" required:"true"` // 必选. API 文档的版本信息(注意:这个版本和开放 API 规范版本没有任何关系)。
Description string `json:"description"` // 对应用的简短描述。 CommonMark syntax 可以被用来表示富文本呈现。
Title string `json:"title" required:"true"` // 必选. 应用的名称。
TermsOfService string `json:"termsOfService"` // 指向服务条款的 URL 地址,必须是 URL 地址格式。
Contact *Contact `json:"contact,omitempty"` // 联系方式
License *License `json:"license,omitempty"` // 开源协议
Version string `json:"version" required:"true"` // 必选. API 文档的版本信息(注意:这个版本和开放 API 规范版本没有任何关系)。
}
// Contact 联系人信息

54
generate.go Normal file
View File

@ -0,0 +1,54 @@
// Package api_doc ...
//
// Description : api_doc ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-07-22 15:55
package api_doc
import (
"git.zhangdeman.cn/gateway/api-doc/define"
"git.zhangdeman.cn/zhangdeman/consts"
)
// NewOpenapiDoc ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:56 2024/7/22
func NewOpenapiDoc() *Generate {
return &Generate{
docData: &define.OpenapiDoc{
Openapi: consts.SwaggerDocVersion3,
Info: &define.Info{
Description: "openapi接口文档",
Title: "openapi接口文档",
TermsOfService: "",
Contact: &define.Contact{
Name: "",
Url: "",
Email: "",
},
License: &define.License{
Name: "",
Url: "",
},
Version: "",
},
Servers: nil,
Components: nil,
Tags: nil,
Paths: nil,
},
}
}
// Generate 文档生成实例
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:57 2024/7/22
type Generate struct {
docData *define.OpenapiDoc
}

2
go.mod
View File

@ -3,7 +3,7 @@ module git.zhangdeman.cn/gateway/api-doc
go 1.22.2
require (
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240425091616-00e0a924efcd
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240722080005-ca68a3ff8bc7
git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20240422034417-8c922be06d95
)

2
go.sum
View File

@ -1,5 +1,7 @@
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240425091616-00e0a924efcd h1:RBFDiEMI97fuzpyb5HBN4lu3UXTAGYo6nlGhV2gWq5U=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240425091616-00e0a924efcd/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240722080005-ca68a3ff8bc7 h1:8wJlcuJPhEHKdNIENvcxGiZwwOgjclvKwgKt/MU6WWI=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240722080005-ca68a3ff8bc7/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211 h1:I/wOsRpCSRkU9vo1u703slQsmK0wnNeZzsWQOGtIAG0=
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211/go.mod h1:SrtvrQRdzt+8KfYzvosH++gWxo2ShPTzR1m3VQ6uX7U=
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240325080031-1f58204e8687 h1:uQcGqdzi4UdpZlp4f4FUPeBqoygP58pEKJkmN3ROsE0=