// 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.RequestDataLocationQuery.String() case http.MethodPost: fallthrough case http.MethodPut: fallthrough case http.MethodPatch: // RFC 5789 fallthrough case http.MethodDelete: return consts.RequestDataLocationBody.String() } return consts.RequestDataLocationQuery.String() } // GetSwaggerType 基于输入的类型, // // Author : go_developer@163.com<白茶清欢> // // Date : 12:23 2024/4/22 func GetSwaggerType(inputType string) string { convertTable := map[string]string{ consts.DataTypeString.String(): "string", consts.DataTypeInt.String(): "integer", consts.DataTypeUint.String(): "integer", consts.DataTypeFloat.String(): "number", consts.DataTypeBool.String(): "boolean", } if _, exist := convertTable[inputType]; exist { return convertTable[inputType] } return inputType }