swagger文档生成 : 增加输入配置的格式化
This commit is contained in:
45
util/tool.go
Normal file
45
util/tool.go
Normal file
@ -0,0 +1,45 @@
|
||||
// Package util ...
|
||||
//
|
||||
// Description : util ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2024-04-22 11:15
|
||||
package util
|
||||
|
||||
import (
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetParameterDefaultLocation 获取参数的默认位置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:16 2024/4/22
|
||||
func GetParameterDefaultLocation(requestMethod string) string {
|
||||
requestMethod = strings.ToUpper(requestMethod)
|
||||
// 没指定参数位置
|
||||
switch requestMethod {
|
||||
case http.MethodGet:
|
||||
fallthrough
|
||||
case http.MethodHead:
|
||||
fallthrough
|
||||
case http.MethodConnect:
|
||||
fallthrough
|
||||
case http.MethodOptions:
|
||||
fallthrough
|
||||
case http.MethodTrace:
|
||||
return consts.RequestLocationQuery
|
||||
case http.MethodPost:
|
||||
fallthrough
|
||||
case http.MethodPut:
|
||||
fallthrough
|
||||
case http.MethodPatch: // RFC 5789
|
||||
fallthrough
|
||||
case http.MethodDelete:
|
||||
return consts.RequestLocationBody
|
||||
}
|
||||
return consts.RequestLocationQuery
|
||||
}
|
Reference in New Issue
Block a user