支持openapi文档的解析 #20
							
								
								
									
										42
									
								
								util/tool.go
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								util/tool.go
									
									
									
									
									
								
							@ -50,15 +50,41 @@ func GetParameterDefaultLocation(requestMethod string) string {
 | 
			
		||||
//
 | 
			
		||||
// 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",
 | 
			
		||||
	for _, itemType := range consts.DataTypeBaseInt {
 | 
			
		||||
		if itemType.String() == inputType {
 | 
			
		||||
			return consts.SwaggerDataTypeInteger
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if _, exist := convertTable[inputType]; exist {
 | 
			
		||||
		return convertTable[inputType]
 | 
			
		||||
	for _, itemType := range consts.DataTypeBaseUint {
 | 
			
		||||
		if itemType.String() == inputType {
 | 
			
		||||
			return consts.SwaggerDataTypeInteger
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for _, itemType := range consts.DataTypeBaseFloat {
 | 
			
		||||
		if itemType.String() == inputType {
 | 
			
		||||
			return consts.SwaggerDataTypeDouble
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for _, itemType := range consts.DataTypeBaseString {
 | 
			
		||||
		if itemType.String() == inputType {
 | 
			
		||||
			return consts.SwaggerDataTypeString
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for _, itemType := range consts.DataTypeBaseString {
 | 
			
		||||
		if itemType.String() == inputType {
 | 
			
		||||
			return consts.SwaggerDataTypeString
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for _, itemType := range consts.DataTypeBaseBool {
 | 
			
		||||
		if itemType.String() == inputType {
 | 
			
		||||
			return consts.SwaggerDataTypeBoolean
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if strings.HasPrefix(inputType, "[]") {
 | 
			
		||||
		return consts.SwaggerDataTypeArray
 | 
			
		||||
	}
 | 
			
		||||
	if strings.HasPrefix(inputType, "map") {
 | 
			
		||||
		return consts.SwaggerDataTypeObject
 | 
			
		||||
	}
 | 
			
		||||
	return inputType
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user