feat: 增加文档数据初始化逻辑

This commit is contained in:
2026-01-06 23:25:14 +08:00
parent 5d86daadeb
commit 3ea5af0709
3 changed files with 172 additions and 116 deletions

33
openapi/option.go Normal file
View File

@@ -0,0 +1,33 @@
// Package openapi ...
//
// Description : openapi ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2026-01-06 22:48
package openapi
import "github.com/getkin/kin-openapi/openapi3"
// OptionFunc 设置文档选项
type OptionFunc func(t *openapi3.T)
// WithServers 设置文档服务器
func WithServers(serverList openapi3.Servers) OptionFunc {
return func(t *openapi3.T) {
if len(serverList) == 0 {
return
}
t.Servers = serverList
}
}
// WithInfo 文档基础信息
func WithInfo(info *openapi3.Info) OptionFunc {
return func(t *openapi3.T) {
if nil == info {
return
}
t.Info = info
}
}