bee icon indicating copy to clipboard operation
bee copied to clipboard

Can not generate swagger with defined structs out side beego project folder

Open taivtse opened this issue 5 years ago • 1 comments

I got a problem when generate swagger document with defined structs out side beego project folder. Message: WARN ▶ 0001 Cannot find the object: common.PagingRequest

My project structure like this: GOPATH: |----bin |----pkg |----src: |--------projectname: |------------front-end-api(beego): |----------------controllers: |--------------------admin.go |------------common: |----------------dtos: |--------------------common.go

Note:

  • front-end-api: beego project foler
  • common: common package using for multiple beego project
  • PagingRequest located inside common.go

Here is my beego version: ├── Beego : 1.12.1 ├── GoVersion : go1.13.10 ├── GOOS : darwin ├── GOARCH : amd64

Please suggest me a solution. Thank you so much.

taivtse avatar May 22 '20 04:05 taivtse

I think bee generate command can not resolve this problem.

func GenerateDocs(curpath string) {
	pkgspath := curpath
	workspace := os.Getenv("BeeWorkspace")
	if workspace != "" {
		pkgspath = workspace
	}
	parsePackagesFromDir(pkgspath)

	fset := token.NewFileSet()
	f, err := parser.ParseFile(fset, filepath.Join(curpath, "routers", "router.go"), nil, parser.ParseComments)
	if err != nil {
		beeLogger.Log.Fatalf("Error while parsing router.go: %s", err)
	}

So, bee uses the current work directory or the value of BeeWorkspace, but it needs file XXX/routers/router.go.

flycash avatar Nov 09 '20 13:11 flycash