1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 05:00:54 +00:00

Added support for ArrayType type definition.

This commit is contained in:
WUMUXIAN 2018-03-16 13:34:54 +08:00
parent 611eecc204
commit c23138b457

View File

@ -927,6 +927,21 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string
} }
// TODO support other types, such as `ArrayType`, `MapType`, `InterfaceType` etc... // TODO support other types, such as `ArrayType`, `MapType`, `InterfaceType` etc...
switch t := ts.Type.(type) { switch t := ts.Type.(type) {
case *ast.ArrayType:
m.Title = k
m.Type = "array"
if isBasicType(fmt.Sprint(t.Elt)) {
typeFormat := strings.Split(basicTypes[fmt.Sprint(t.Elt)], ":")
m.Format = typeFormat[0]
} else {
objectName := packageName + "." + fmt.Sprint(t.Elt)
if _, ok := rootapi.Definitions[objectName]; !ok {
objectName, _, _ = getModel(objectName)
}
m.Items = &swagger.Schema{
Ref: "#/definitions/" + objectName,
}
}
case *ast.Ident: case *ast.Ident:
parseIdent(t, k, m, astPkgs) parseIdent(t, k, m, astPkgs)
case *ast.StructType: case *ast.StructType: