mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
Made the example value for enum type sensitive.
This commit is contained in:
parent
be6186155f
commit
611eecc204
@ -947,7 +947,7 @@ func parseIdent(st *ast.Ident, k string, m *swagger.Schema, astPkgs []*ast.Packa
|
||||
m.Format = typeFormat[1]
|
||||
}
|
||||
enums := make(map[int]string)
|
||||
enumValues := make(map[int]string)
|
||||
enumValues := make(map[int]interface{})
|
||||
for _, pkg := range astPkgs {
|
||||
for _, fl := range pkg.Files {
|
||||
for _, obj := range fl.Scope.Objects {
|
||||
@ -975,7 +975,25 @@ func parseIdent(st *ast.Ident, k string, m *swagger.Schema, astPkgs []*ast.Packa
|
||||
continue
|
||||
}
|
||||
enums[int(val.Pos())] = fmt.Sprintf("%s = %s", vs.Names[i].Name, v.Value)
|
||||
enumValues[int(val.Pos())] = v.Value
|
||||
switch v.Kind {
|
||||
case token.INT:
|
||||
vv, err := strconv.Atoi(v.Value)
|
||||
if err != nil {
|
||||
beeLogger.Log.Warnf("Unknown type with BasicLit to int: %v\n", v.Value)
|
||||
continue
|
||||
}
|
||||
enumValues[int(val.Pos())] = vv
|
||||
case token.FLOAT:
|
||||
vv, err := strconv.ParseFloat(v.Value, 64)
|
||||
if err != nil {
|
||||
beeLogger.Log.Warnf("Unknown type with BasicLit to int: %v\n", v.Value)
|
||||
continue
|
||||
}
|
||||
enumValues[int(val.Pos())] = vv
|
||||
default:
|
||||
enumValues[int(val.Pos())] = strings.Trim(v.Value, `"`)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user