feat: 增加文档数据初始化逻辑
This commit is contained in:
33
openapi/option.go
Normal file
33
openapi/option.go
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user