From 254174eda61f27a545d0a0880afbb499d4dcbc93 Mon Sep 17 00:00:00 2001 From: zhangyanzhe Date: Wed, 19 Jul 2017 14:42:46 +0800 Subject: [PATCH 01/29] array format --- generate/swaggergen/g_docs.go | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index be54679a5..061b9f8e0 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -612,10 +612,25 @@ func parserComments(f *ast.FuncDecl, controllerName, pkgpath string) error { pp := strings.Split(p[2], ".") typ := pp[len(pp)-1] if len(pp) >= 2 { + isArray := false + if p[1] == "body" || p[1] == "formData" || strings.HasPrefix(p[2], "[]") { + p[2] = p[2][2:] + isArray = true + } m, mod, realTypes := getModel(p[2]) - para.Schema = &swagger.Schema{ - Ref: "#/definitions/" + m, + if isArray { + para.Schema = &swagger.Schema{ + Type: "array", + Items: &swagger.Schema{ + Ref: "#/definitions/" + m, + }, + } + } else { + para.Schema = &swagger.Schema{ + Ref: "#/definitions/" + m, + } } + if _, ok := modelsList[pkgpath+controllerName]; !ok { modelsList[pkgpath+controllerName] = make(map[string]swagger.Schema) } @@ -762,10 +777,12 @@ func setParamType(para *swagger.Parameter, typ string, pkgpath, controllerName s appendModels(pkgpath, controllerName, realTypes) } if isArray { - para.Type = "array" - para.Items = &swagger.ParameterItems{ - Type: paraType, - Format: paraFormat, + para.Schema = &swagger.Schema{ + Type: "array", + Items: &swagger.Schema{ + Type: paraType, + Format: paraFormat, + }, } } else { para.Type = paraType From 2b04261f9cd4e7079dd4ce3babd1ad729472edfb Mon Sep 17 00:00:00 2001 From: zhangyanzhe Date: Wed, 19 Jul 2017 14:47:19 +0800 Subject: [PATCH 02/29] array format --- generate/swaggergen/g_docs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 061b9f8e0..6c0548979 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -613,7 +613,7 @@ func parserComments(f *ast.FuncDecl, controllerName, pkgpath string) error { typ := pp[len(pp)-1] if len(pp) >= 2 { isArray := false - if p[1] == "body" || p[1] == "formData" || strings.HasPrefix(p[2], "[]") { + if (p[1] == "body" || p[1] == "formData") && strings.HasPrefix(p[2], "[]") { p[2] = p[2][2:] isArray = true } From d0b3ede4ec297c4d9838af1395074bb01ea28417 Mon Sep 17 00:00:00 2001 From: zhangyanzhe Date: Wed, 19 Jul 2017 15:38:04 +0800 Subject: [PATCH 03/29] array format --- generate/swaggergen/g_docs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 6c0548979..922b93d25 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -613,7 +613,7 @@ func parserComments(f *ast.FuncDecl, controllerName, pkgpath string) error { typ := pp[len(pp)-1] if len(pp) >= 2 { isArray := false - if (p[1] == "body" || p[1] == "formData") && strings.HasPrefix(p[2], "[]") { + if p[1] == "body" && strings.HasPrefix(p[2], "[]") { p[2] = p[2][2:] isArray = true } From 58bfa5c1ec37231cb532af06b89ebaebef845167 Mon Sep 17 00:00:00 2001 From: zhangyanzhe Date: Wed, 19 Jul 2017 15:49:54 +0800 Subject: [PATCH 04/29] array format --- generate/swaggergen/g_docs.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 922b93d25..441bba92a 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -777,12 +777,20 @@ func setParamType(para *swagger.Parameter, typ string, pkgpath, controllerName s appendModels(pkgpath, controllerName, realTypes) } if isArray { - para.Schema = &swagger.Schema{ - Type: "array", - Items: &swagger.Schema{ + if para.In == "body" { + para.Schema = &swagger.Schema{ + Type: "array", + Items: &swagger.Schema{ + Type: paraType, + Format: paraFormat, + }, + } + } else { + para.Type = "array" + para.Items = &swagger.ParameterItems{ Type: paraType, Format: paraFormat, - }, + } } } else { para.Type = paraType From 52e3087bb45acbe55458e9bd82adcd1504dde76a Mon Sep 17 00:00:00 2001 From: Adrian Ancona Novelo Date: Sat, 16 Sep 2017 14:24:22 +0800 Subject: [PATCH 05/29] Only import the correct driver when doing a migration. Fixes #447 --- cmd/commands/migrate/migrate.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/commands/migrate/migrate.go b/cmd/commands/migrate/migrate.go index 187094593..92fa16e9c 100644 --- a/cmd/commands/migrate/migrate.go +++ b/cmd/commands/migrate/migrate.go @@ -196,6 +196,17 @@ func checkForSchemaUpdateTable(db *sql.DB, driver string) { } } +func driverImportStatement(driver string) string { + switch driver { + case "mysql": + return "github.com/go-sql-driver/mysql" + case "postgres": + return "github.com/lib/pq" + default: + return "github.com/go-sql-driver/mysql" + } +} + func showMigrationsTableSQL(driver string) string { switch driver { case "mysql": @@ -263,6 +274,7 @@ func writeMigrationSourceFile(dir, source, driver, connStr string, latestTime in beeLogger.Log.Fatalf("Could not create file: %s", err) } else { content := strings.Replace(MigrationMainTPL, "{{DBDriver}}", driver, -1) + content = strings.Replace(content, "{{DriverRepo}}", driverImportStatement(driver), -1) content = strings.Replace(content, "{{ConnStr}}", connStr, -1) content = strings.Replace(content, "{{LatestTime}}", strconv.FormatInt(latestTime, 10), -1) content = strings.Replace(content, "{{LatestName}}", latestName, -1) @@ -346,8 +358,7 @@ import( "github.com/astaxie/beego/orm" "github.com/astaxie/beego/migration" - _ "github.com/go-sql-driver/mysql" - _ "github.com/lib/pq" + _ "{{DriverRepo}}" ) func init(){ From a5cddac55492d4b6ca4c7ab97cd5f0383f4bb31a Mon Sep 17 00:00:00 2001 From: Vladimir Alaev Date: Wed, 4 Oct 2017 16:54:05 +0300 Subject: [PATCH 06/29] Fix docs generator to ignore all child folders of the vendor folder within project dir --- generate/swaggergen/g_docs.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 642c26361..1d758db7b 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -105,11 +105,12 @@ func ParsePackagesFromDir(dirpath string) { return nil } - // 7 is length of 'vendor' (6) + length of file path separator (1) - // so we skip dir 'vendor' which is directly under dirpath - if !(len(fpath) == len(dirpath)+7 && strings.HasSuffix(fpath, "vendor")) && + // skip folder if it's a 'vendor' folder within dirpath or its child, + // all 'tests' folders and dot folders wihin dirpath + d, _ := filepath.Rel(dirpath, fpath) + if !(d == "vendor" || strings.HasPrefix(d, "vendor"+string(os.PathSeparator))) && !strings.Contains(fpath, "tests") && - !(len(fpath) > len(dirpath) && fpath[len(dirpath)+1] == '.') { + !(d[0] == '.') { err = parsePackageFromDir(fpath) if err != nil { // Send the error to through the channel and continue walking From c34cb05355c59a8c3692095cd1b50322d52c1a72 Mon Sep 17 00:00:00 2001 From: TankTheFrank Date: Thu, 19 Oct 2017 13:39:59 +0300 Subject: [PATCH 07/29] after build the browser is refreshed --- cmd/commands/run/watch.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/commands/run/watch.go b/cmd/commands/run/watch.go index 825b7b97b..1a3c13267 100644 --- a/cmd/commands/run/watch.go +++ b/cmd/commands/run/watch.go @@ -86,6 +86,12 @@ func NewWatcher(paths []string, files []string, isgenerate bool) { scheduleTime = time.Now().Add(1 * time.Second) time.Sleep(scheduleTime.Sub(time.Now())) AutoBuild(files, isgenerate) + + if config.Conf.EnableReload { + // Wait 100ms more before refreshing the browser + time.Sleep(100 * time.Millisecond) + sendReload(e.String()) + } }() } case err := <-watcher.Errors: From f8e9f67ae62322afa36c7db00cde048715cbf989 Mon Sep 17 00:00:00 2001 From: Haojin Gui Date: Tue, 17 Oct 2017 17:38:56 -0700 Subject: [PATCH 08/29] Add empty line. --- cmd/commands/generate/generate.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/commands/generate/generate.go b/cmd/commands/generate/generate.go index 2fa8cbed1..993ff3f5b 100644 --- a/cmd/commands/generate/generate.go +++ b/cmd/commands/generate/generate.go @@ -166,6 +166,7 @@ func appCode(cmd *commands.Command, args []string, currpath string) { beeLogger.Log.Infof("Using '%s' as 'Level'", generate.Level) generate.GenerateAppcode(generate.SQLDriver.String(), generate.SQLConn.String(), generate.Level.String(), generate.Tables.String(), currpath) } + func migration(cmd *commands.Command, args []string, currpath string) { if len(args) < 2 { beeLogger.Log.Fatal("Wrong number of arguments. Run: bee help generate") From 7d78224b99be15d86c473f64722570c35a5e1106 Mon Sep 17 00:00:00 2001 From: Haojin Gui Date: Tue, 17 Oct 2017 21:06:42 -0700 Subject: [PATCH 09/29] Remove redundant selectedTables. When selectedTables is not nil, we are already generating tables from it. So we don't need to pass it further. --- generate/g_appcode.go | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/generate/g_appcode.go b/generate/g_appcode.go index 155bad5f6..260472a37 100644 --- a/generate/g_appcode.go +++ b/generate/g_appcode.go @@ -318,7 +318,7 @@ func gen(dbms, connStr string, mode byte, selectedTableNames map[string]bool, ap mvcPath.RouterPath = path.Join(apppath, "routers") createPaths(mode, mvcPath) pkgPath := getPackagePath(apppath) - writeSourceFiles(pkgPath, tables, mode, mvcPath, selectedTableNames) + writeSourceFiles(pkgPath, tables, mode, mvcPath) } else { beeLogger.Log.Fatalf("Generating app code from '%s' database is not supported yet.", dbms) } @@ -728,32 +728,26 @@ func createPaths(mode byte, paths *MvcPath) { // writeSourceFiles generates source files for model/controller/router // It will wipe the following directories and recreate them:./models, ./controllers, ./routers // Newly geneated files will be inside these folders. -func writeSourceFiles(pkgPath string, tables []*Table, mode byte, paths *MvcPath, selectedTables map[string]bool) { +func writeSourceFiles(pkgPath string, tables []*Table, mode byte, paths *MvcPath) { if (OModel & mode) == OModel { beeLogger.Log.Info("Creating model files...") - writeModelFiles(tables, paths.ModelPath, selectedTables) + writeModelFiles(tables, paths.ModelPath) } if (OController & mode) == OController { beeLogger.Log.Info("Creating controller files...") - writeControllerFiles(tables, paths.ControllerPath, selectedTables, pkgPath) + writeControllerFiles(tables, paths.ControllerPath, pkgPath) } if (ORouter & mode) == ORouter { beeLogger.Log.Info("Creating router files...") - writeRouterFile(tables, paths.RouterPath, selectedTables, pkgPath) + writeRouterFile(tables, paths.RouterPath, pkgPath) } } // writeModelFiles generates model files -func writeModelFiles(tables []*Table, mPath string, selectedTables map[string]bool) { +func writeModelFiles(tables []*Table, mPath string) { w := colors.NewColorWriter(os.Stdout) for _, tb := range tables { - // if selectedTables map is not nil and this table is not selected, ignore it - if selectedTables != nil { - if _, selected := selectedTables[tb.Name]; !selected { - continue - } - } filename := getFileName(tb.Name) fpath := path.Join(mPath, filename+".go") var f *os.File @@ -806,16 +800,10 @@ func writeModelFiles(tables []*Table, mPath string, selectedTables map[string]bo } // writeControllerFiles generates controller files -func writeControllerFiles(tables []*Table, cPath string, selectedTables map[string]bool, pkgPath string) { +func writeControllerFiles(tables []*Table, cPath string, pkgPath string) { w := colors.NewColorWriter(os.Stdout) for _, tb := range tables { - // If selectedTables map is not nil and this table is not selected, ignore it - if selectedTables != nil { - if _, selected := selectedTables[tb.Name]; !selected { - continue - } - } if tb.Pk == "" { continue } @@ -854,17 +842,11 @@ func writeControllerFiles(tables []*Table, cPath string, selectedTables map[stri } // writeRouterFile generates router file -func writeRouterFile(tables []*Table, rPath string, selectedTables map[string]bool, pkgPath string) { +func writeRouterFile(tables []*Table, rPath string, pkgPath string) { w := colors.NewColorWriter(os.Stdout) var nameSpaces []string for _, tb := range tables { - // If selectedTables map is not nil and this table is not selected, ignore it - if selectedTables != nil { - if _, selected := selectedTables[tb.Name]; !selected { - continue - } - } if tb.Pk == "" { continue } From 4711873e25ff3bc5d5f41262af05fa88c031cb7e Mon Sep 17 00:00:00 2001 From: ilylia Date: Mon, 13 Nov 2017 14:29:44 +0800 Subject: [PATCH 10/29] support enum, except iota and type inference. --- generate/swaggergen/g_docs.go | 67 +++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 642c26361..1e17aa29d 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -896,10 +896,71 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string beeLogger.Log.Fatalf("Unknown type without TypeSec: %v\n", d) } // TODO support other types, such as `ArrayType`, `MapType`, `InterfaceType` etc... - st, ok := ts.Type.(*ast.StructType) - if !ok { - return + switch t := ts.Type.(type) { + case *ast.Ident: + parseIdent(k, m, astPkgs) + case *ast.StructType: + parseStruct(t, k, m, realTypes, astPkgs, packageName) } +} + +// parse as enum +func parseIdent(k string, m *swagger.Schema, astPkgs []*ast.Package) { + m.Title = k + for _, pkg := range astPkgs { + for _, fl := range pkg.Files { + for _, obj := range fl.Scope.Objects { + if obj.Kind == ast.Con { + vs, ok := obj.Decl.(*ast.ValueSpec) + if !ok { + beeLogger.Log.Fatalf("Unknown type without ValueSpec: %v\n", vs) + } + ti, ok := vs.Type.(*ast.Ident) + if !ok { + // TODO type inference, iota not support yet + continue + } + if ti.Name != k { + continue + } + for _, val := range vs.Values { + v, ok := val.(*ast.BasicLit) + if !ok { + beeLogger.Log.Warnf("Unknown type without BasicLit: %v\n", v) + continue + } + rawV := strings.Trim(v.Value, `"`) + switch v.Kind { + case token.INT: + vv, err := strconv.Atoi(rawV) + if err != nil { + beeLogger.Log.Warnf("Unknown type with BasicLit to int: %v\n", rawV) + continue + } + m.Enum = append(m.Enum, vv) + case token.FLOAT: + vv, err := strconv.ParseFloat(rawV, 64) + if err != nil { + beeLogger.Log.Warnf("Unknown type with BasicLit to int: %v\n", rawV) + continue + } + m.Enum = append(m.Enum, vv) + //case token.IMAG: + // rawV := strings.Trim(v.Value, `i`) + // m.Enum = append(m.Enum, strconv.ParseFloat(rawV, 64)) + case token.CHAR: + m.Enum = append(m.Enum, rawV) + case token.STRING: + m.Enum = append(m.Enum, rawV) + } + } + } + } + } + } +} + +func parseStruct(st *ast.StructType, k string, m *swagger.Schema, realTypes *[]string, astPkgs []*ast.Package, packageName string) { m.Title = k if st.Fields.List != nil { m.Properties = make(map[string]swagger.Propertie) From 363abeeae24f8bdb80528f516e0738fafd5d9a63 Mon Sep 17 00:00:00 2001 From: hemin Date: Mon, 20 Nov 2017 16:32:19 +0800 Subject: [PATCH 11/29] add swagger spec support for struct embedded field --- generate/swaggergen/g_docs.go | 36 ++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 872c9b093..25f6574d9 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -1092,14 +1092,40 @@ func parseStruct(st *ast.StructType, k string, m *swagger.Schema, realTypes *[]s continue } } else { - for _, pkg := range astPkgs { - for _, fl := range pkg.Files { - for nameOfObj, obj := range fl.Scope.Objects { - if obj.Name == fmt.Sprint(field.Type) { - parseObject(obj, nameOfObj, m, realTypes, astPkgs, pkg.Name) + // only parse case of when embedded field is TypeName + // cases of *TypeName and Interface are not handled, maybe useless for swagger spec + tag := "" + if field.Tag != nil { + stag := reflect.StructTag(strings.Trim(field.Tag.Value, "`")) + tag = stag.Get("json") + } + + if tag != "" { + tagValues := strings.Split(tag, ",") + if tagValues[0] == "-" { + //if json tag is "-", omit + continue + } else { + //if json tag is "something", output: something #definition/pkgname.Type + m.Properties[tagValues[0]] = mp + continue + } + } else { + //if no json tag, expand all fields of the type here + nm := &swagger.Schema{} + for _, pkg := range astPkgs { + for _, fl := range pkg.Files { + for nameOfObj, obj := range fl.Scope.Objects { + if obj.Name == fmt.Sprint(field.Type) { + parseObject(obj, nameOfObj, nm, realTypes, astPkgs, pkg.Name) + } } } } + for name, p := range nm.Properties { + m.Properties[name] = p + } + continue } } } From 4ab8b8e30eac0c9c303f915363de4c65629bd3b6 Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 27 Nov 2017 15:51:45 +0800 Subject: [PATCH 12/29] bee 1.9.1 --- cmd/commands/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/commands/version/version.go b/cmd/commands/version/version.go index ada9427d3..fd9b249c8 100644 --- a/cmd/commands/version/version.go +++ b/cmd/commands/version/version.go @@ -57,7 +57,7 @@ Prints the current Bee, Beego and Go version alongside the platform information. } var outputFormat string -const version = "1.9.1" +const version = "1.9.2" func init() { fs := flag.NewFlagSet("version", flag.ContinueOnError) From fdf0e9c768f231a2d10af756aef2a21c3b296d5a Mon Sep 17 00:00:00 2001 From: xhzhang Date: Thu, 21 Dec 2017 23:32:40 +0800 Subject: [PATCH 13/29] feat: support bee workspace specify support bee workspace specify instead of current path only --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index beccb06d6..ef51e0d0e 100644 --- a/main.go +++ b/main.go @@ -25,9 +25,15 @@ import ( "github.com/beego/bee/utils" ) +var ( + workspace = os.Getenv("BeeWorkspace") +) + func main() { currentpath, _ := os.Getwd() - + if workspace != "" { + currentpath = workspace + } flag.Usage = cmd.Usage flag.Parse() log.SetFlags(0) @@ -66,7 +72,6 @@ func main() { if utils.IsInGOPATH(currentpath) && cmd.IfGenerateDocs(c.Name(), args) { swaggergen.ParsePackagesFromDir(currentpath) } - os.Exit(c.Run(c, args)) return } From 418230b131ab27eff557d2b8a35734e0e8609e1f Mon Sep 17 00:00:00 2001 From: Faissal Elamraoui Date: Thu, 21 Dec 2017 17:30:50 +0100 Subject: [PATCH 14/29] Fix TravisCI badge --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e4920a87b..92b9e7a16 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ bee Bee is a command-line tool facilitating development of Beego-based application. -[![Build Status](https://drone.io/github.com/beego/bee/status.png)](https://drone.io/github.com/beego/bee/latest) +[![Build Status](https://img.shields.io/travis/beego/bee.svg?branch=master&label=master)](https://travis-ci.org/beego/bee) +[![Build Status](https://img.shields.io/travis/beego/bee.svg?branch=develop&label=develop)](https://travis-ci.org/beego/bee) ## Requirements From d70cedc7de6f03a833aa369e2923173b9384148d Mon Sep 17 00:00:00 2001 From: Terry Ding Date: Thu, 28 Dec 2017 00:47:14 +0800 Subject: [PATCH 15/29] fix issue #501 --- generate/swaggergen/g_docs.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 25f6574d9..8c7340c2c 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -1225,6 +1225,8 @@ func str2RealType(s string, typ string) interface{} { switch typ { case "int", "int64", "int32", "int16", "int8": ret, err = strconv.Atoi(s) + case "uint", "uint64", "uint32", "uint16", "uint8": + ret, err = strconv.ParseUint(s, 10, 0) case "bool": ret, err = strconv.ParseBool(s) case "float64": From 5ba8b15e3aa6de7ba36e527a8fb7146e08533c36 Mon Sep 17 00:00:00 2001 From: lixz <361293862@qq.com> Date: Fri, 29 Dec 2017 17:09:02 +0800 Subject: [PATCH 16/29] Update watch.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在window编译linux后,bee run 执行的appname为linux的可执行文件 --- cmd/commands/run/watch.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/commands/run/watch.go b/cmd/commands/run/watch.go index 825b7b97b..1b463ee69 100644 --- a/cmd/commands/run/watch.go +++ b/cmd/commands/run/watch.go @@ -139,9 +139,9 @@ func AutoBuild(files []string, isgenerate bool) { } beeLogger.Log.Success("Docs generated!") } - + appName := appname if err == nil { - appName := appname + if runtime.GOOS == "windows" { appName += ".exe" } @@ -165,7 +165,7 @@ func AutoBuild(files []string, isgenerate bool) { } beeLogger.Log.Success("Built Successfully!") - Restart(appname) + Restart(appName) } // Kill kills the running command process From 4f53288e6ab7538939e512f908684e6b7bc4501b Mon Sep 17 00:00:00 2001 From: Louise van der Lith Date: Tue, 9 Jan 2018 10:49:57 +0200 Subject: [PATCH 17/29] v.Fun can't always be converted to *ast.SelectorExpr. Added a check to confirm that the object is correct. --- generate/swaggergen/g_docs.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 642c26361..0aced9122 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -261,8 +261,9 @@ func GenerateDocs(curpath string) { case *ast.AssignStmt: for _, l := range stmt.Rhs { if v, ok := l.(*ast.CallExpr); ok { - // Analyse NewNamespace, it will return version and the subfunction - if selName := v.Fun.(*ast.SelectorExpr).Sel.String(); selName != "NewNamespace" { + // Analyze NewNamespace, it will return version and the subfunction + selExpr, selOK := v.Fun.(*ast.SelectorExpr) + if !selOK || selExpr.Sel.Name != "NewNamespace" { continue } version, params := analyseNewNamespace(v) From d217d0b85c1d9eaca83e38168dbdf2b34c499c65 Mon Sep 17 00:00:00 2001 From: WUMUXIAN Date: Sat, 10 Mar 2018 17:35:59 +0800 Subject: [PATCH 18/29] Swagger: 1. Improve the enum support, the enum will be in a format of "enum_name = enum_value" 2. An example value will be automatically generated. 3. Example is disabled for slice field. --- generate/swaggergen/g_docs.go | 62 +++++++++++++---------------------- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 263bd0910..f55d22cba 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -925,15 +925,24 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string // TODO support other types, such as `ArrayType`, `MapType`, `InterfaceType` etc... switch t := ts.Type.(type) { case *ast.Ident: - parseIdent(k, m, astPkgs) + parseIdent(t, k, m, astPkgs) case *ast.StructType: parseStruct(t, k, m, realTypes, astPkgs, packageName) } } // parse as enum -func parseIdent(k string, m *swagger.Schema, astPkgs []*ast.Package) { +func parseIdent(st *ast.Ident, k string, m *swagger.Schema, astPkgs []*ast.Package) { m.Title = k + basicType := fmt.Sprint(st) + if object, isStdLibObject := stdlibObject[basicType]; isStdLibObject { + basicType = object + } + if k, ok := basicTypes[basicType]; ok { + typeFormat := strings.Split(k, ":") + m.Type = typeFormat[0] + m.Format = typeFormat[1] + } for _, pkg := range astPkgs { for _, fl := range pkg.Files { for _, obj := range fl.Scope.Objects { @@ -942,44 +951,11 @@ func parseIdent(k string, m *swagger.Schema, astPkgs []*ast.Package) { if !ok { beeLogger.Log.Fatalf("Unknown type without ValueSpec: %v\n", vs) } - ti, ok := vs.Type.(*ast.Ident) - if !ok { - // TODO type inference, iota not support yet - continue - } - if ti.Name != k { - continue - } - for _, val := range vs.Values { - v, ok := val.(*ast.BasicLit) - if !ok { - beeLogger.Log.Warnf("Unknown type without BasicLit: %v\n", v) - continue - } - rawV := strings.Trim(v.Value, `"`) - switch v.Kind { - case token.INT: - vv, err := strconv.Atoi(rawV) - if err != nil { - beeLogger.Log.Warnf("Unknown type with BasicLit to int: %v\n", rawV) - continue - } - m.Enum = append(m.Enum, vv) - case token.FLOAT: - vv, err := strconv.ParseFloat(rawV, 64) - if err != nil { - beeLogger.Log.Warnf("Unknown type with BasicLit to int: %v\n", rawV) - continue - } - m.Enum = append(m.Enum, vv) - //case token.IMAG: - // rawV := strings.Trim(v.Value, `i`) - // m.Enum = append(m.Enum, strconv.ParseFloat(rawV, 64)) - case token.CHAR: - m.Enum = append(m.Enum, rawV) - case token.STRING: - m.Enum = append(m.Enum, rawV) - } + enum := fmt.Sprintf("%s = %v", vs.Names[0].Name, vs.Names[0].Obj.Data) + m.Enum = append(m.Enum, enum) + // Automatically give an example. + if m.Example == nil { + m.Example = vs.Names[0].Obj.Data } } } @@ -1005,6 +981,7 @@ func parseStruct(st *ast.StructType, k string, m *swagger.Schema, realTypes *[]s } *realTypes = append(*realTypes, realType) mp := swagger.Propertie{} + isObject := false if isSlice { mp.Type = "array" if isBasicType(strings.Replace(realType, "[]", "", -1)) { @@ -1020,6 +997,7 @@ func parseStruct(st *ast.StructType, k string, m *swagger.Schema, realTypes *[]s } } else { if sType == "object" { + isObject = true mp.Ref = "#/definitions/" + realType } else if isBasicType(realType) { typeFormat := strings.Split(sType, ":") @@ -1087,6 +1065,10 @@ func parseStruct(st *ast.StructType, k string, m *swagger.Schema, realTypes *[]s mp.Description = desc } + if example := stag.Get("example"); example != "" && !isObject && !isSlice { + mp.Example = str2RealType(example, realType) + } + m.Properties[name] = mp } if ignore := stag.Get("ignore"); ignore != "" { From 685c16d5ebc29b8efc7e16ec46a047b27ca50094 Mon Sep 17 00:00:00 2001 From: Muxian Wu Date: Mon, 12 Mar 2018 15:52:00 +0800 Subject: [PATCH 19/29] Swagger Enum Fix: 1. For now the type inference is not supported, they will be skipped. 2. The enums in the documentation will be listed based on it's position. 3. Be able to support multiple values defined. --- generate/swaggergen/g_docs.go | 46 ++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index f55d22cba..3750d191c 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -27,6 +27,7 @@ import ( "reflect" "regexp" "runtime" + "sort" "strconv" "strings" "unicode" @@ -93,6 +94,7 @@ func init() { astPkgs = make([]*ast.Package, 0) } +// ParsePackagesFromDir parses packages from a given directory func ParsePackagesFromDir(dirpath string) { c := make(chan error) @@ -145,6 +147,7 @@ func parsePackageFromDir(path string) error { return nil } +// GenerateDocs generates documentations for a given path. func GenerateDocs(curpath string) { fset := token.NewFileSet() @@ -931,7 +934,7 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string } } -// parse as enum +// parse as enum, in the package, find out all consts with the same type func parseIdent(st *ast.Ident, k string, m *swagger.Schema, astPkgs []*ast.Package) { m.Title = k basicType := fmt.Sprint(st) @@ -943,6 +946,8 @@ func parseIdent(st *ast.Ident, k string, m *swagger.Schema, astPkgs []*ast.Packa m.Type = typeFormat[0] m.Format = typeFormat[1] } + enums := make(map[int]string) + enumValues := make(map[int]string) for _, pkg := range astPkgs { for _, fl := range pkg.Files { for _, obj := range fl.Scope.Objects { @@ -951,16 +956,45 @@ func parseIdent(st *ast.Ident, k string, m *swagger.Schema, astPkgs []*ast.Packa if !ok { beeLogger.Log.Fatalf("Unknown type without ValueSpec: %v\n", vs) } - enum := fmt.Sprintf("%s = %v", vs.Names[0].Name, vs.Names[0].Obj.Data) - m.Enum = append(m.Enum, enum) - // Automatically give an example. - if m.Example == nil { - m.Example = vs.Names[0].Obj.Data + + ti, ok := vs.Type.(*ast.Ident) + if !ok { + // TODO type inference, iota not support yet + continue + } + // Only add the enums that are defined by the current identifier + if ti.Name != k { + continue + } + + // For all names and values, aggregate them by it's position so that we can sort them later. + for i, val := range vs.Values { + v, ok := val.(*ast.BasicLit) + if !ok { + beeLogger.Log.Warnf("Unknown type without BasicLit: %v\n", v) + continue + } + enums[int(val.Pos())] = fmt.Sprintf("%s = %s", vs.Names[i].Name, v.Value) + enumValues[int(val.Pos())] = v.Value } } } } } + // Sort the enums by position + if len(enums) > 0 { + var keys []int + for k := range enums { + keys = append(keys, k) + } + sort.Ints(keys) + for _, k := range keys { + m.Enum = append(m.Enum, enums[k]) + } + // Automatically use the first enum value as the example. + m.Example = enumValues[keys[0]] + } + } func parseStruct(st *ast.StructType, k string, m *swagger.Schema, realTypes *[]string, astPkgs []*ast.Package, packageName string) { From 611eecc204e6bc5f3084d4f755820d5c65a1f1ca Mon Sep 17 00:00:00 2001 From: Muxian Wu Date: Thu, 15 Mar 2018 18:05:37 +0800 Subject: [PATCH 20/29] Made the example value for enum type sensitive. --- generate/swaggergen/g_docs.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 3750d191c..2cb8fd567 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -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, `"`) + } + } } } From c23138b457e3cf147bd50e98e9de1a946ede028e Mon Sep 17 00:00:00 2001 From: WUMUXIAN Date: Fri, 16 Mar 2018 13:34:54 +0800 Subject: [PATCH 21/29] Added support for ArrayType type definition. --- generate/swaggergen/g_docs.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 2cb8fd567..96a15b0cc 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -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... 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: parseIdent(t, k, m, astPkgs) case *ast.StructType: From cb47a5a5fe4e7ab01ff2e46f20f7d03cbdaf1bf8 Mon Sep 17 00:00:00 2001 From: zhongyijun Date: Fri, 23 Mar 2018 14:29:39 +0800 Subject: [PATCH 22/29] fix api path contain regex string bug --- generate/swaggergen/g_docs.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 642c26361..1fee76a55 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -1100,6 +1100,12 @@ func urlReplace(src string) string { } else if p[0] == '?' && p[1] == ':' { pt[i] = "{" + p[2:] + "}" } + + if pt[i][0] == '{' && strings.Contains(pt[i], ":") { + pt[i] = pt[i][:strings.Index(pt[i], ":")] + "}" + } else if pt[i][0] == '{' && strings.Contains(pt[i], "(") { + pt[i] = pt[i][:strings.Index(pt[i], "(")] + "}" + } } } return strings.Join(pt, "/") From c1896dd4cf361be5dcaf63b88aa4cf4b66b3c04b Mon Sep 17 00:00:00 2001 From: qida Date: Tue, 27 Mar 2018 15:08:24 +0800 Subject: [PATCH 23/29] Update ignoredFilesRegExps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决了在执行 `bee run -gendoc=true` 时,更新`commentsRouter_controllers.go`文件导致多次触发"build"的bug。 --- cmd/commands/run/watch.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/commands/run/watch.go b/cmd/commands/run/watch.go index 825b7b97b..95386b6f0 100644 --- a/cmd/commands/run/watch.go +++ b/cmd/commands/run/watch.go @@ -43,6 +43,7 @@ var ( `.(\w+).go.swp`, `(\w+).go~`, `(\w+).tmp`, + `commentsRouter_controllers.go`, } ) From bb68873f45713334c5e75620b201656a415f7145 Mon Sep 17 00:00:00 2001 From: guoshaowei Date: Thu, 10 May 2018 14:37:03 +0800 Subject: [PATCH 24/29] fix *time.Time type parse error. --- cmd/commands/version/version.go | 2 +- generate/swaggergen/g_docs.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/commands/version/version.go b/cmd/commands/version/version.go index ada9427d3..fd9b249c8 100644 --- a/cmd/commands/version/version.go +++ b/cmd/commands/version/version.go @@ -57,7 +57,7 @@ Prints the current Bee, Beego and Go version alongside the platform information. } var outputFormat string -const version = "1.9.1" +const version = "1.9.2" func init() { fs := flag.NewFlagSet("version", flag.ContinueOnError) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 642c26361..8c2f06079 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -77,7 +77,7 @@ var basicTypes = map[string]string{ "byte": "string:byte", "rune": "string:byte", // builtin golang objects - "time.Time": "string:string", + "time.Time": "string:datetime", } var stdlibObject = map[string]string{ @@ -919,7 +919,7 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string mp := swagger.Propertie{} if isSlice { mp.Type = "array" - if isBasicType(strings.Replace(realType, "[]", "", -1)) { + if sType, ok := basicTypes[(strings.Replace(realType, "[]", "", -1))]; ok { typeFormat := strings.Split(sType, ":") mp.Items = &swagger.Propertie{ Type: typeFormat[0], @@ -1035,6 +1035,9 @@ func typeAnalyser(f *ast.Field) (isSlice bool, realType, swaggerType string) { switch t := f.Type.(type) { case *ast.StarExpr: basicType := fmt.Sprint(t.X) + if object, isStdLibObject := stdlibObject[basicType]; isStdLibObject { + basicType = object + } if k, ok := basicTypes[basicType]; ok { return false, basicType, k } From 25063a62c4fb24ea1d0bc0707213f69842aae10e Mon Sep 17 00:00:00 2001 From: Medicean Date: Mon, 11 Jun 2018 18:01:35 +0800 Subject: [PATCH 25/29] fix bee.json & Beefile watch_ext doesn't work --- Beefile | 3 ++- bee.json | 3 ++- cmd/commands/run/watch.go | 4 ++-- config/conf.go | 6 +++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Beefile b/Beefile index d77b2c578..1e0ec8755 100644 --- a/Beefile +++ b/Beefile @@ -1,6 +1,7 @@ version: 0 go_install: false -watch_ext: [] +watch_ext: [".go"] +watch_ext_static: [".html", ".tpl", ".js", ".css"] dir_structure: watch_all: false controllers: "" diff --git a/bee.json b/bee.json index 50cbd0e7a..f31454272 100644 --- a/bee.json +++ b/bee.json @@ -1,7 +1,8 @@ { "version": 0, "go_install": false, - "watch_ext": [], + "watch_ext": [".go"], + "watch_ext_static": [".html", ".tpl", ".js", ".css"], "dir_structure": { "watch_all": false, "controllers": "", diff --git a/cmd/commands/run/watch.go b/cmd/commands/run/watch.go index 825b7b97b..af1f47496 100644 --- a/cmd/commands/run/watch.go +++ b/cmd/commands/run/watch.go @@ -36,8 +36,8 @@ var ( state sync.Mutex eventTime = make(map[string]int64) scheduleTime time.Time - watchExts = []string{".go"} - watchExtsStatic = []string{".html", ".tpl", ".js", ".css"} + watchExts = config.Conf.WatchExts + watchExtsStatic = config.Conf.WatchExtsStatic ignoredFilesRegExps = []string{ `.#(\w+).go`, `.(\w+).go.swp`, diff --git a/config/conf.go b/config/conf.go index eebbce242..9232bb638 100644 --- a/config/conf.go +++ b/config/conf.go @@ -27,6 +27,8 @@ const confVer = 0 var Conf = struct { Version int + WatchExts []string `json:"watch_ext" yaml:"watch_ext"` + WatchExtsStatic []string `json:"watch_ext_static" yaml:"watch_ext_static"` GoInstall bool `json:"go_install" yaml:"go_install"` // Indicates whether execute "go install" before "go build". DirStruct dirStruct `json:"dir_structure" yaml:"dir_structure"` CmdArgs []string `json:"cmd_args" yaml:"cmd_args"` @@ -37,7 +39,9 @@ var Conf = struct { EnableNotification bool `json:"enable_notification" yaml:"enable_notification"` Scripts map[string]string `json:"scripts" yaml:"scripts"` }{ - GoInstall: true, + WatchExts: []string{".go"}, + WatchExtsStatic: []string{".html", ".tpl", ".js", ".css"}, + GoInstall: true, DirStruct: dirStruct{ Others: []string{}, }, From cd82742af9f21c94daece7d63a0d39830356c79d Mon Sep 17 00:00:00 2001 From: Codeb Fan Date: Tue, 26 Jun 2018 18:07:49 +0800 Subject: [PATCH 26/29] Support extra args to run application. --- cmd/commands/run/run.go | 3 +++ cmd/commands/run/watch.go | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/commands/run/run.go b/cmd/commands/run/run.go index 2010e5fe5..17f73dbab 100644 --- a/cmd/commands/run/run.go +++ b/cmd/commands/run/run.go @@ -58,6 +58,8 @@ var ( currentGoPath string // Current runmode runmode string + // Extra args to run application + runargs string // Extra directories extraPackages utils.StrFlags ) @@ -71,6 +73,7 @@ func init() { CmdRun.Flag.BoolVar(&vendorWatch, "vendor", false, "Enable watch vendor folder.") CmdRun.Flag.StringVar(&buildTags, "tags", "", "Set the build tags. See: https://golang.org/pkg/go/build/") CmdRun.Flag.StringVar(&runmode, "runmode", "", "Set the Beego run mode.") + CmdRun.Flag.StringVar(&runargs, "runargs", "", "Extra args to run application") CmdRun.Flag.Var(&extraPackages, "ex", "List of extra package to watch.") exit = make(chan bool) commands.AvailableCommands = append(commands.AvailableCommands, CmdRun) diff --git a/cmd/commands/run/watch.go b/cmd/commands/run/watch.go index 825b7b97b..b06e69ac8 100644 --- a/cmd/commands/run/watch.go +++ b/cmd/commands/run/watch.go @@ -200,7 +200,13 @@ func Start(appname string) { cmd = exec.Command(appname) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - cmd.Args = append([]string{appname}, config.Conf.CmdArgs...) + if runargs != "" { + r := regexp.MustCompile("'.+'|\".+\"|\\S+") + m := r.FindAllString(runargs, -1) + cmd.Args = append([]string{appname}, m...) + } else { + cmd.Args = append([]string{appname}, config.Conf.CmdArgs...) + } cmd.Env = append(os.Environ(), config.Conf.Envs...) go cmd.Run() From 815bdd737a61939d51790883150e970cec7d9362 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 21 Jul 2018 23:06:23 +0800 Subject: [PATCH 27/29] update to go version 1.10.3 --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ed9150ae4..04803113b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: go go: - - 1.6.3 - - 1.7.3 - - 1.8 + - 1.10.3 install: - export PATH=$PATH:$HOME/gopath/bin - go get -u github.com/opennota/check/cmd/structcheck From b05f8ace9e5f74fbd36052fd71b19be6f75b95a4 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sun, 22 Jul 2018 11:59:24 +0800 Subject: [PATCH 28/29] update dep --- generate/swaggergen/g_docs.go | 30 +++++++++---------- vendor/github.com/astaxie/beego/LICENSE | 13 -------- .../astaxie/beego/swagger/swagger.go | 4 ++- vendor/vendor.json | 6 ++-- 4 files changed, 21 insertions(+), 32 deletions(-) delete mode 100644 vendor/github.com/astaxie/beego/LICENSE diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index da0968fa3..351a289bc 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -353,21 +353,21 @@ func analyseNewNamespace(ce *ast.CallExpr) (first string, others []ast.Expr) { func analyseNSInclude(baseurl string, ce *ast.CallExpr) string { cname := "" for _, p := range ce.Args { - var x *ast.SelectorExpr - var p1 interface{} = p - if ident, ok := p1.(*ast.Ident); ok { - if assign, ok := ident.Obj.Decl.(*ast.AssignStmt); ok { - if len(assign.Rhs) > 0 { - p1 = assign.Rhs[0].(*ast.UnaryExpr) - } - } - } - if _, ok := p1.(*ast.UnaryExpr); ok { - x = p1.(*ast.UnaryExpr).X.(*ast.CompositeLit).Type.(*ast.SelectorExpr) - } else { - beeLogger.Log.Warnf("Couldn't determine type\n") - continue - } + var x *ast.SelectorExpr + var p1 interface{} = p + if ident, ok := p1.(*ast.Ident); ok { + if assign, ok := ident.Obj.Decl.(*ast.AssignStmt); ok { + if len(assign.Rhs) > 0 { + p1 = assign.Rhs[0].(*ast.UnaryExpr) + } + } + } + if _, ok := p1.(*ast.UnaryExpr); ok { + x = p1.(*ast.UnaryExpr).X.(*ast.CompositeLit).Type.(*ast.SelectorExpr) + } else { + beeLogger.Log.Warnf("Couldn't determine type\n") + continue + } if v, ok := importlist[fmt.Sprint(x.X)]; ok { cname = v + x.Sel.Name } diff --git a/vendor/github.com/astaxie/beego/LICENSE b/vendor/github.com/astaxie/beego/LICENSE deleted file mode 100644 index 5dbd42435..000000000 --- a/vendor/github.com/astaxie/beego/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2014 astaxie - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file diff --git a/vendor/github.com/astaxie/beego/swagger/swagger.go b/vendor/github.com/astaxie/beego/swagger/swagger.go index 89fef8a68..a55676cdc 100644 --- a/vendor/github.com/astaxie/beego/swagger/swagger.go +++ b/vendor/github.com/astaxie/beego/swagger/swagger.go @@ -121,6 +121,8 @@ type Schema struct { Type string `json:"type,omitempty" yaml:"type,omitempty"` Items *Schema `json:"items,omitempty" yaml:"items,omitempty"` Properties map[string]Propertie `json:"properties,omitempty" yaml:"properties,omitempty"` + Enum []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"` + Example interface{} `json:"example,omitempty" yaml:"example,omitempty"` } // Propertie are taken from the JSON Schema definition but their definitions were adjusted to the Swagger Specification @@ -130,7 +132,7 @@ type Propertie struct { Description string `json:"description,omitempty" yaml:"description,omitempty"` Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` - Example string `json:"example,omitempty" yaml:"example,omitempty"` + Example interface{} `json:"example,omitempty" yaml:"example,omitempty"` Required []string `json:"required,omitempty" yaml:"required,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"` ReadOnly bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"` diff --git a/vendor/vendor.json b/vendor/vendor.json index 37ef0d8c0..52b43bafd 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -3,10 +3,10 @@ "ignore": "test", "package": [ { - "checksumSHA1": "OeOvZ+3A1tRBdMD8GuS6R9zcnqA=", + "checksumSHA1": "/ffb74fNK251iTEebGjybfFBAbs=", "path": "github.com/astaxie/beego/swagger", - "revision": "323a1c4214101331a4b71922c23d19b7409ac71f", - "revisionTime": "2017-03-06T13:59:04Z" + "revision": "a09bafbf2ab483742b17bb352f95dbc0a597e720", + "revisionTime": "2018-07-21T07:55:28Z" }, { "checksumSHA1": "epd3Y7nD7QVzTW0ppwK+q4pKo/4=", From 5ed819a025fae24c4c5312a8a4c28b26a6987e7a Mon Sep 17 00:00:00 2001 From: astaxie Date: Sun, 22 Jul 2018 12:06:22 +0800 Subject: [PATCH 29/29] version 1.10.0 --- cmd/commands/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/commands/version/version.go b/cmd/commands/version/version.go index fd9b249c8..779b75865 100644 --- a/cmd/commands/version/version.go +++ b/cmd/commands/version/version.go @@ -57,7 +57,7 @@ Prints the current Bee, Beego and Go version alongside the platform information. } var outputFormat string -const version = "1.9.2" +const version = "1.10.0" func init() { fs := flag.NewFlagSet("version", flag.ContinueOnError)