Closed ajeyprasad closed 6 years ago
Sample Code :
package xyz
type Metadata struct{ id string json:"id,omitempty" key string json:"key,omitempty" } package abc
json:"id,omitempty"
json:"key,omitempty"
import "xyz"
type Entity struct { xyz.Metadata Name string json:"name,omitempty" }
json:"name,omitempty"
If i try to generate Doc using swag init. But getting following error
2018/01/31 17:29:34 Generate swagger docs.... 2018/01/31 17:29:34 Generate general API Info panic: runtime error: index out of range
goroutine 1 [running]: github.com/swaggo/swag.(Parser).ParseDefinitions(0xc0421445c0) C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/parser.go:196 +0x652 github.com/swaggo/swag.(Parser).ParseApi(0xc0421445c0, 0x7d4eb9, 0x2, 0x7d64ae, 0x9) C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/parser.go:70 +0x26f github.com/swaggo/swag/gen.(Gen).Build(0xc042059b50, 0x7d4eb9, 0x2, 0x7d64ae, 0x9, 0x0, 0x0) C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/gen/gen.go:27 +0x382 main.main.func1(0xc04206c2c0, 0xc04224c100, 0xc04206c2c0) C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/cmd/swag/main.go:23 +0x5c github.com/urfave/cli.HandleAction(0x759d60, 0x7ec5e8, 0xc04206c2c0, 0x0, 0xc0421c6120) C:/Users/gangab5/go/src/PersistenceService/src/github.com/urfave/cli/app.go:501 +0xd9 github.com/urfave/cli.Command.Run(0x7d54ca, 0x4, 0x0, 0x0, 0xc04224c0f0, 0x1, 0x1, 0x7d7f8e, 0xe, 0x0, ...) C:/Users/gangab5/go/src/PersistenceService/src/github.com/urfave/cli/command.go:165 +0x4c2 github.com/urfave/cli.(App).Run(0xc04202e000, 0xc0420023c0, 0x2, 0x2, 0x0, 0x0) C:/Users/gangab5/go/src/PersistenceService/src/github.com/urfave/cli/app.go:259 +0x747 main.main() C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/cmd/swag/main.go:29 +0x1bd
Please help.
This should be posted to swaggo/swag, not swaggo/gin-swagger.
@ajeyprasad we add support for anonymous field, please use the latest version of swag.
swag
@ajeyprasad Please reopen it if you have any questions. 😄
Sample Code :
package xyz
type Metadata struct{ id string
json:"id,omitempty"
key stringjson:"key,omitempty"
} package abcimport "xyz"
type Entity struct { xyz.Metadata Name string
json:"name,omitempty"
}If i try to generate Doc using swag init. But getting following error
2018/01/31 17:29:34 Generate swagger docs.... 2018/01/31 17:29:34 Generate general API Info panic: runtime error: index out of range
goroutine 1 [running]: github.com/swaggo/swag.(Parser).ParseDefinitions(0xc0421445c0) C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/parser.go:196 +0x652 github.com/swaggo/swag.(Parser).ParseApi(0xc0421445c0, 0x7d4eb9, 0x2, 0x7d64ae, 0x9) C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/parser.go:70 +0x26f github.com/swaggo/swag/gen.(Gen).Build(0xc042059b50, 0x7d4eb9, 0x2, 0x7d64ae, 0x9, 0x0, 0x0) C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/gen/gen.go:27 +0x382 main.main.func1(0xc04206c2c0, 0xc04224c100, 0xc04206c2c0) C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/cmd/swag/main.go:23 +0x5c github.com/urfave/cli.HandleAction(0x759d60, 0x7ec5e8, 0xc04206c2c0, 0x0, 0xc0421c6120) C:/Users/gangab5/go/src/PersistenceService/src/github.com/urfave/cli/app.go:501 +0xd9 github.com/urfave/cli.Command.Run(0x7d54ca, 0x4, 0x0, 0x0, 0xc04224c0f0, 0x1, 0x1, 0x7d7f8e, 0xe, 0x0, ...) C:/Users/gangab5/go/src/PersistenceService/src/github.com/urfave/cli/command.go:165 +0x4c2 github.com/urfave/cli.(App).Run(0xc04202e000, 0xc0420023c0, 0x2, 0x2, 0x0, 0x0) C:/Users/gangab5/go/src/PersistenceService/src/github.com/urfave/cli/app.go:259 +0x747 main.main() C:/Users/gangab5/go/src/PersistenceService/src/github.com/swaggo/swag/cmd/swag/main.go:29 +0x1bd
Please help.