Comments (17)
@ankghoro Did you add GOPATH/bin
in your PATH
environment variable?
PATH=$PATH:$(go env GOPATH)/bin
from swag.
@pilere can you provide your sample code?
from swag.
No really, I just run swag init on my project (gin-gonic API)
where conf.GetMeActifResult is the struct type GetMeActifResult defined in the package conf imported within my code ....
type GetMeActifResult struct {
....
}
c:\mycode>swag init
2017/10/13 09:30:30 Generate swagger docs....
2017/10/13 09:30:30 Generate general API Info
2017/10/13 09:30:30 ParseComment panic:Can not find ref type:"conf.GetMeActifResult".
panic: ParseComment panic:Can not find ref type:"conf.GetMeActifResult".
goroutine 1 [running]:
panic(0x718d40, 0xc04215a760)
C:/Go/src/runtime/panic.go:500 +0x1af
log.Panicf(0x79c700, 0x16, 0xc04246f4b0, 0x1, 0x1)
C:/Go/src/log/log.go:327 +0xea
github.com/swaggo/swag.(*Parser).ParseRouterApiInfo(0xc04232c780, 0xc042338300)
D:/www/src/github.com/swaggo/swag/parser.go:135 +0x61f
github.com/swaggo/swag.(*Parser).ParseApi(0xc04232c780, 0x79587c, 0x2, 0x79743b, 0x9)
D:/www/src/github.com/swaggo/swag/parser.go:67 +0x28d
github.com/swaggo/swag/gen.(*Gen).Build(0xc04246f8d0, 0x79587c, 0x2, 0x79743b, 0x9, 0x0, 0x0)
D:/www/src/github.com/swaggo/swag/gen/gen.go:27 +0x4ad
main.main.func1(0xc04206a9a0, 0x0, 0xc04206a9a0)
D:/www/src/github.com/pilere/swag/cmd/swag/main.go:21 +0x5c
github.com/urfave/cli.HandleAction(0x725c60, 0x7c2da0, 0xc04206a9a0, 0xc0421f2200, 0x0)
D:/www/src/github.com/urfave/cli/app.go:490 +0xdb
github.com/urfave/cli.Command.Run(0x796036, 0x4, 0x0, 0x0, 0xc0423de110, 0x1, 0x1, 0x7994b9, 0xe, 0x0, ...)
D:/www/src/github.com/urfave/cli/command.go:210 +0xbc0
github.com/urfave/cli.(*App).Run(0xc04201c9c0, 0xc04200c700, 0x2, 0x2, 0x0, 0x0)
D:/www/src/github.com/urfave/cli/app.go:255 +0x7b9
main.main()
D:/www/src/github.com/pilere/swag/cmd/swag/main.go:27 +0x143
from swag.
@pilere You had reference conf.GetMeActifResult
struct type in your main.go which contains https://github.com/swaggo/swag#declarative-comments-format that swag can't find it.
I guess that some declarative comments format have wrong usage.
Can you show your main.go
file ?
from swag.
yes, I do use :
// @success 200 {array} conf.GetMeActifResult
in the comment of the API
and have a small comment on the struct definition conf.GetMeActifResult :
// GetMeActifResult utilise uniquement comme type de data pour swagger api result
type GetMeActifResult struct {
.......
}
I see no informations on how to set comments for structures here :
https://github.com/swaggo/swag#declarative-comments-format
the sample his :
type Pet3 struct {
ID int json:"id"
}
with no comment and not used within the api sample above ....
Stéphane
from swag.
@pilere Sorry for my late replay. I had created https://github.com/easonlin404/swag-test and worked for me FYR.
Or maybe you can show your project file structure.
from swag.
That's exactly like that ... I don't get it, it should work ...
I will try to add some debug of the scan ....
Thanks for your help, I will keep you informed.
from swag.
After some debugging, I found that the parser itself has some
inconsistency ... in the function "func (parser *Parser) ParseDefinitions() {"
if I add a dump or "parser" I got this :
[DEBUG] parser &{swagger:0xc042034400 files:map[apifile1.go:0xc042273c00 apifile2.go:0xc0423b7900 apifile3.go:0xc042372600 docs\docs.go:0xc042372900 main.go:0xc04233a700 apifile4.go:0xc042272d80 apifile5.go:0xc042273600 apifile6.go:0xc0423b7100 apifile7.go:0xc042272180 apifile8.go:0xc042273e80 apifile9.go:0xc04233a180 apifile10.go:0xc042272280 TypeDefinitions:map[main:map[DB:0xc042237080] docs:map[s:0xc042122630]] registerTypes:map[conf.GetMeActifResult:]}
EDIT : I don't see the package conf/structures.go read here ...
2017/10/16 11:26:28 [DEBUG DEFINITIONS] refTypeName conf.GetMeActifResult et typeSpec
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x4d864d]
the API is defined in the main package but the conf.GetMeActifResult is defined in the conf package .. I will try to change your test to match it !
Stéphane
from swag.
pfff you were right from the beginning ...
I set up my app in multiple folder but with multiple executable.
The API is one
Some Nodes are others
and ALL are sharing the conf.
so I got this kind of folder tree
/API
/API/main.go (with import ../conf)
/API/file2.go
/conf
/conf/structure.go
/nodes
/nodes/blabla.go
so I launch the swag init within API but the /conf is one step under ... so it's not parsed ....
Your example look like the same with the API in one folder and the conf another BUT the main.go is under it and we launch the swag init inside it !
I need to find a way to scan ../conf from within /API
Stéphane
from swag.
@pilere ok, I will find a way to support it if main.go
is not under root folder.
from swag.
if you could provide support for time.Time as a structure field, that would be great too :
in your swag-test package : conf.go
package conf
import "time"
// GetMeActifResult utilise uniquement comme type de data pour swagger api result
type GetMeActifResult struct {
ID int `json:"id"`
CreatedAt time.Time
}
you get :
\swag-test-master>swag init
2017/10/18 09:32:10 Generate swagger docs....
2017/10/18 09:32:10 Generate general API Info
panic: not supported 'astSelectorExpr' yet.
goroutine 1 [running]:
panic(0x719040, 0xc042305060)
C:/Go/src/runtime/panic.go:500 +0x1af
github.com/swaggo/swag.getPropertyName(0xc042270b80, 0xc0422a4c90, 0xc04211f120)
D:/www/src/github.com/swaggo/swag/property.go:12 +0x9e
github.com/swaggo/swag.(*Parser).ParseDefinitions(0xc04234be00)
D:/www/src/github.com/swaggo/swag/parser.go:193 +0x390
github.com/swaggo/swag.(*Parser).ParseApi(0xc04234be00, 0x795bfc, 0x2, 0x7977bf, 0x9)
D:/www/src/github.com/swaggo/swag/parser.go:70 +0x2b6
github.com/swaggo/swag/gen.(*Gen).Build(0xc04211f8c0, 0x795bfc, 0x2, 0x7977bf, 0x9, 0x0, 0x0)
D:/www/src/github.com/swaggo/swag/gen/gen.go:27 +0x4ad
main.main.func1(0xc042074840, 0x0, 0xc042074840)
D:/www/src/github.com/swaggo/swag/cmd/swag/main.go:21 +0x5c
github.com/urfave/cli.HandleAction(0x725f60, 0x7c3140, 0xc042074840, 0xc04203cf00, 0x0)
D:/www/src/github.com/urfave/cli/app.go:502 +0xdb
github.com/urfave/cli.Command.Run(0x7963ba, 0x4, 0x0, 0x0, 0xc04238dce0, 0x1, 0x1, 0x79983d, 0xe, 0x0, ...)
D:/www/src/github.com/urfave/cli/command.go:210 +0xbd9
github.com/urfave/cli.(*App).Run(0xc042282000, 0xc0420383e0, 0x2, 0x2, 0x0, 0x0)
D:/www/src/github.com/urfave/cli/app.go:259 +0x801
main.main()
D:/www/src/github.com/swaggo/swag/cmd/swag/main.go:27 +0x143
That would be great ... for now I am stuck with the fact that I need only one error code by error ... I was using this :
// GetMeActifs
// @Summary GetMeActifs Get the list of actifs
// @Description get all the actifs
// @Accept json
// @Produce json
// @Success 200 {array} conf.GetMeActifResult
// @Failure 403 {string} StatusForbidden "Forbiden"
// @Failure 404 {string} StatusNotFound "No User Found"
// @Failure 404 {string} StatusNotFound "No Owner Found"
// @Router /actifs [get]
which is not tolerated by swagger :
// @failure 404 {string} StatusNotFound "No User Found"
// @failure 404 {string} StatusNotFound "No Owner Found"
I need to find either a way out or to use another error code but then it's silly as it should be a 404 ....
Stéphane
from swag.
@pilere Did you still have the issue?
from swag.
@easonlin404 I didn't try the new version if you changed it ... are your talking of the first one with the conf folder at the same level than the project or the second one with the parsing of the same error code for 2 errors ?
Stéphane
from swag.
@pilere please reopen it if you still have this issue.
from swag.
How to generate swag binary file?
As when I run swag init command, an error displaying command: swag not found
from swag.
@shantanuaggarwal2695 please download swag by using:
$ go get -u github.com/swaggo/swag/cmd/swag
from swag.
Hello @easonlin404 for me still not work, i already download by
go get -u github.com/swaggo/swag/cmd/swag
Please help
from swag.
Related Issues (20)
- swag init HOT 5
- Install swag v2 (OpenAPI 3.1) HOT 2
- Include field in schema but hide from examples HOT 1
- Is is possible to make the fixed example value for a specified type?
- @tag.description.markdown does not select the correct markdown file if tag is a substring of another tag
- Add the ability to read from stdin and write to stdout.
- field of `any` type behaves badly when specifying `json` field name HOT 1
- Global override `any` type uses incorrect schema HOT 1
- API operation annotations must be followed by a func?
- How to set displayRequestDuration ?
- Bad operation when there is a newline character between annotations
- Add Redocly UI Theme
- Add a way to specify a parameter for multiple routes at once
- example/celler unknown field LeftDelim HOT 2
- Dynamically set swagger version with semantic-release HOT 1
- Bug: --parseDependency generates documentation for external packages HOT 2
- Docs not generated for pkg folder
- Method names for typescript are not generated according to the annotations when two routes have a similar prefix HOT 1
- Support swagger type format for global override
- [V2] feat: supports bearer token security tag
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swag.