mirror of
https://github.com/beego/bee.git
synced 2024-11-22 10:10:53 +00:00
fix the map type generate
This commit is contained in:
parent
205428abce
commit
29c9e1bab7
18
g_docs.go
18
g_docs.go
@ -683,12 +683,18 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if isBasicType(realType) {
|
if sType == "object" {
|
||||||
|
mp.Ref = "#/definitions/" + realType
|
||||||
|
} else if isBasicType(realType) {
|
||||||
typeFormat := strings.Split(sType, ":")
|
typeFormat := strings.Split(sType, ":")
|
||||||
mp.Type = typeFormat[0]
|
mp.Type = typeFormat[0]
|
||||||
mp.Format = typeFormat[1]
|
mp.Format = typeFormat[1]
|
||||||
} else if sType == "object" {
|
} else if realType == "map" {
|
||||||
mp.Ref = "#/definitions/" + realType
|
typeFormat := strings.Split(sType, ":")
|
||||||
|
mp.AdditionalProperties = &swagger.Propertie{
|
||||||
|
Type: typeFormat[0],
|
||||||
|
Format: typeFormat[1],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if field.Names != nil {
|
if field.Names != nil {
|
||||||
@ -768,7 +774,11 @@ func typeAnalyser(f *ast.Field) (isSlice bool, realType, swaggerType string) {
|
|||||||
case *ast.StarExpr:
|
case *ast.StarExpr:
|
||||||
return false, fmt.Sprint(t.X), "object"
|
return false, fmt.Sprint(t.X), "object"
|
||||||
case *ast.MapType:
|
case *ast.MapType:
|
||||||
return false, fmt.Sprint(t.Value), "object"
|
val := fmt.Sprintf("%v", t.Value)
|
||||||
|
if isBasicType(val) {
|
||||||
|
return false, "map", basicTypes[val]
|
||||||
|
}
|
||||||
|
return false, val, "object"
|
||||||
}
|
}
|
||||||
if k, ok := basicTypes[fmt.Sprint(f.Type)]; ok {
|
if k, ok := basicTypes[fmt.Sprint(f.Type)]; ok {
|
||||||
return false, fmt.Sprint(f.Type), k
|
return false, fmt.Sprint(f.Type), k
|
||||||
|
Loading…
Reference in New Issue
Block a user