Ai
1 Star 1 Fork 1

百家饭/apinx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
def.go 759 Bytes
一键复制 编辑 原始数据 按行查看 历史
Liu Ming 提交于 2023-04-07 09:38 +08:00 . 1)支持post json时的自动参数解密
package openapi
import (
"strings"
"github.com/getkin/kin-openapi/openapi3"
)
func AddMethod(def *openapi3.T, path, method string) (*openapi3.Operation, string) {
if def.Paths == nil {
def.Paths = openapi3.Paths{}
}
var pDef *openapi3.PathItem
if pDef = def.Paths[path]; pDef == nil {
pDef = new(openapi3.PathItem)
}
method = strings.ToLower(method)
var op = new(openapi3.Operation)
switch method {
case "get":
pDef.Get = op
case "post":
pDef.Post = op
case "put":
pDef.Put = op
case "delete":
pDef.Delete = op
case "options":
pDef.Options = op
case "head":
pDef.Head = op
case "patch":
pDef.Patch = op
case "trace":
pDef.Trace = op
case "connect":
pDef.Connect = op
}
def.Paths[path] = pDef
return op, method
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bjf-fhe/apinx.git
git@gitee.com:bjf-fhe/apinx.git
bjf-fhe
apinx
apinx
v0.1.0

搜索帮助