Skip to content

Commit

Permalink
feat: pass --pd option to swag; bump timeout to 30s
Browse files Browse the repository at this point in the history
  • Loading branch information
LeslieLeung committed Dec 19, 2023
1 parent 694c04d commit ccd3fe8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 6 additions & 2 deletions internal/yaag/swag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import (
"os/exec"
)

func RunSwag() {
func RunSwag(parseDependency bool) {
general := "./main.go"
if YaagConfig != nil && YaagConfig.SwagGeneral != "" {
general = YaagConfig.SwagGeneral
}
cmd := exec.Command("swag", "init", "-g", general, "-o", "./docs", "-ot", "json")
args := []string{"init", "-g", general, "-o", "./docs", "--ot", "json"}
if parseDependency {
args = append(args, "--pd")
}
cmd := exec.Command("swag", args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
Expand Down
16 changes: 9 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ import (
)

var (
docDir string
mergeMode string
isInit bool
upload bool
timeout int
docDir string
mergeMode string
isInit bool
upload bool
timeout int
parseDependency bool
)

func init() {
flag.StringVar(&docDir, "docDir", "", "path to swagger.json")
flag.StringVar(&mergeMode, "mergeMode", "", "merge mode")
flag.BoolVar(&isInit, "init", false, "init")
flag.BoolVar(&upload, "upload", false, "upload only, no swag generate")
flag.IntVar(&timeout, "timeout", 10, "timeout in seconds")
flag.IntVar(&timeout, "timeout", 30, "timeout in seconds, default is 30s")
flag.BoolVar(&parseDependency, "pd", false, "parse dependency, pass directly to swag")
flag.Parse()
}

Expand All @@ -32,7 +34,7 @@ func main() {
yaag.GetConfig()
mergeOptions()
if !upload {
yaag.RunSwag()
yaag.RunSwag(parseDependency)
swagger.Convert(docDir)
}
resp := yaag.UpdateYapi(docDir, mergeMode, timeout)
Expand Down

0 comments on commit ccd3fe8

Please sign in to comment.