Open easonlin404 opened 5 years ago
May be not exactly the same. I got this error message in windows 10. @easonlin404
swag init -g app/main/mian.go
2019/07/06 18:23:38 Generate swagger docs....
2019/07/06 18:23:39 Generate general API Info, search dir:./
2019/07/06 18:23:39 execute go list command, exit status 1, stdout:, stderr:can't load package: package swag-test: unknown import path "swag-test": cannot find module providing package swag-test
Ok, I will dig this issue later, thanks for your report.
@easonlin404 Thank you for your help. By the way, there is another problem in nested struct when generating the document. If I have a struct below, if will generate a strange string.
//@Success 200 {object} Foo
type Foo struct {
Field1 []struct{
Field2 uint
Field3 string
}
}
The document will like this
Foo {
Field1 [&{%!s(token.Pos=1046) %!s(*ast.FieldList=&{1053 [0xc00036a080 0xc00036a0c0 0xc00036a100 0xc00036a140 0xc00036a180 0xc00036a200 0xc00036a240 0xc00036a280 0xc00036a2c0 0xc00036a300 0xc00036a340 0xc00036a3c0 0xc00036a480] 1695}) %!s(bool=false)}]
}
I also want to know if any method to use the anonymous structures to generating document. For example, I just use this struct once in the router handler function like below and I don't want to name them.
response := struct {
Code int `json:"code"`
Data []struct{
Field1 uint `json:"field1"`
Field2 string `json:"field2"`
}
}{}
return c.JSON(200, response)
@blxzfb307 this issue have been fixed by https://github.com/swaggo/swag/commit/91ec3e69be3fcd78e18b7f4d19f9a1785f36919d. Please go get -u github.com/swaggo/swag/cmd/swag
to get v1.6.1 should be work.
For anonymous structures issue, it's kind of difficult to fix it, but would be do my best to support all of cases for anonymous structures, and you can raise the issue at https://github.com/swaggo/swag/issues, I would be fix for it.
@easonlin404 sorry for bothering you again, the problem still exists in v1.6.1. Here is the screenshot.
Should shown swag-test/app/main via go list cmd , I’m not sure that if related with windows platform, but I can fix enable with go list when —parsingDependency flag on.
Here is the screenshot of go list. It has a same error message if I use the relative path.
Thanks for your informations, I would disable go list if not specify flag —parsingDependency=on.
@blxzfb307 please use the latest v1.6.2 to try again, thx.
It works now, thanks!
I got error message like below, it's same as u? @blxzfb307