Compare commits
2 Commits
master
...
feature/fi
Author | SHA1 | Date | |
---|---|---|---|
5afe9bed09 | |||
0899ad9fe6 |
18
common.go
18
common.go
@ -47,24 +47,34 @@ func GetUriPathParamList(uriPath string) []*define.ParamConfig {
|
||||
// Date : 11:52 2024/12/24
|
||||
func GetDataType(docParamType string, formatType string) string {
|
||||
docParamType = strings.ToLower(docParamType)
|
||||
formatType = strings.ToLower(formatType)
|
||||
formatType = strings.ReplaceAll(strings.ToLower(formatType), "interface{}", "any") // 内置支持的类型统一使用any, 不使用 interface{}
|
||||
if len(formatType) == 0 {
|
||||
formatType = docParamType
|
||||
}
|
||||
// format type 和内置的支持数据类型一致, 直接返回对应类型
|
||||
for _, itemType := range consts.DataTypeList {
|
||||
if itemType.Value.String() == formatType {
|
||||
return itemType.Value.String()
|
||||
}
|
||||
}
|
||||
|
||||
// format type 和内置的支持数据类型不一致, 根据文档类型进行转换
|
||||
switch docParamType {
|
||||
case consts.SwaggerDataTypeInteger:
|
||||
if formatType == "int64" {
|
||||
if formatType == consts.DataTypeInt.String() {
|
||||
return consts.DataTypeInt.String()
|
||||
}
|
||||
return consts.DataTypeUint.String()
|
||||
return consts.DataTypeInt.String()
|
||||
case "string", "apikey":
|
||||
return consts.DataTypeString.String()
|
||||
case "object":
|
||||
return consts.DataTypeMapStrAny.String()
|
||||
case "boolean":
|
||||
return consts.DataTypeBool.String()
|
||||
case "number", "float", "double", "float32", "float64":
|
||||
case "number", "float", "double", "float64":
|
||||
return consts.DataTypeFloat64.String()
|
||||
case "float32":
|
||||
return consts.DataTypeFloat32.String()
|
||||
case "array":
|
||||
if formatType == "integer" {
|
||||
return consts.DataTypeSliceInt.String()
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -129,7 +130,7 @@ func (su *SwaggerUI) HandleLuckyUI() func(ctx *gin.Context) {
|
||||
// su.router.StaticFS(su.baseUri+"/assets", http.FS(ydocUIFiles))
|
||||
return func(ctx *gin.Context) {
|
||||
fileRealPath := strings.TrimPrefix(ctx.Request.RequestURI, su.baseUri)
|
||||
byteData, _ := ydocUIFiles.ReadFile(define.SwaggerUIThemeYDocLucky + fileRealPath)
|
||||
byteData, _ := ydocUIFiles.ReadFile(filepath.Join(define.SwaggerUIThemeYDocLucky, fileRealPath))
|
||||
if strings.HasSuffix(ctx.Request.RequestURI, "html") {
|
||||
byteData = []byte(strings.ReplaceAll(string(byteData), "{{BASE_URI}}", su.baseUri))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user