mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
Merge pull request #462 from gigovich/develop
Fix #438. Fix random module matching from swagger generator.
This commit is contained in:
commit
0405523d35
@ -52,7 +52,7 @@ var importlist map[string]string
|
|||||||
var controllerList map[string]map[string]*swagger.Item //controllername Paths items
|
var controllerList map[string]map[string]*swagger.Item //controllername Paths items
|
||||||
var modelsList map[string]map[string]swagger.Schema
|
var modelsList map[string]map[string]swagger.Schema
|
||||||
var rootapi swagger.Swagger
|
var rootapi swagger.Swagger
|
||||||
var astPkgs map[string]*ast.Package
|
var astPkgs []*ast.Package
|
||||||
|
|
||||||
// refer to builtin.go
|
// refer to builtin.go
|
||||||
var basicTypes = map[string]string{
|
var basicTypes = map[string]string{
|
||||||
@ -89,7 +89,7 @@ func init() {
|
|||||||
importlist = make(map[string]string)
|
importlist = make(map[string]string)
|
||||||
controllerList = make(map[string]map[string]*swagger.Item)
|
controllerList = make(map[string]map[string]*swagger.Item)
|
||||||
modelsList = make(map[string]map[string]swagger.Schema)
|
modelsList = make(map[string]map[string]swagger.Schema)
|
||||||
astPkgs = map[string]*ast.Package{}
|
astPkgs = make([]*ast.Package, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParsePackagesFromDir(dirpath string) {
|
func ParsePackagesFromDir(dirpath string) {
|
||||||
@ -136,8 +136,8 @@ func parsePackageFromDir(path string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range folderPkgs {
|
for _, v := range folderPkgs {
|
||||||
astPkgs[k] = v
|
astPkgs = append(astPkgs, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -860,14 +860,16 @@ func getModel(str string) (objectname string, m swagger.Schema, realTypes []stri
|
|||||||
packageName := ""
|
packageName := ""
|
||||||
m.Type = "object"
|
m.Type = "object"
|
||||||
for _, pkg := range astPkgs {
|
for _, pkg := range astPkgs {
|
||||||
for _, fl := range pkg.Files {
|
if strs[0] == pkg.Name {
|
||||||
for k, d := range fl.Scope.Objects {
|
for _, fl := range pkg.Files {
|
||||||
if d.Kind == ast.Typ {
|
for k, d := range fl.Scope.Objects {
|
||||||
if k != objectname {
|
if d.Kind == ast.Typ {
|
||||||
continue
|
if k != objectname {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
packageName = pkg.Name
|
||||||
|
parseObject(d, k, &m, &realTypes, astPkgs, pkg.Name)
|
||||||
}
|
}
|
||||||
packageName = pkg.Name
|
|
||||||
parseObject(d, k, &m, &realTypes, astPkgs, pkg.Name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -885,7 +887,7 @@ func getModel(str string) (objectname string, m swagger.Schema, realTypes []stri
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string, astPkgs map[string]*ast.Package, packageName string) {
|
func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string, astPkgs []*ast.Package, packageName string) {
|
||||||
ts, ok := d.Decl.(*ast.TypeSpec)
|
ts, ok := d.Decl.(*ast.TypeSpec)
|
||||||
if !ok {
|
if !ok {
|
||||||
beeLogger.Log.Fatalf("Unknown type without TypeSec: %v\n", d)
|
beeLogger.Log.Fatalf("Unknown type without TypeSec: %v\n", d)
|
||||||
|
Loading…
Reference in New Issue
Block a user