-
Notifications
You must be signed in to change notification settings - Fork 134
/
main.go
51 lines (44 loc) · 1019 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
log "github.com/sirupsen/logrus"
)
const (
swaggerGenDir = "./gen"
swaggerFilePath = "./swagger.yaml"
)
func generateSwagger() error {
cwd, err := os.Getwd()
if err != nil {
return err
}
swaggerGenDirFull := filepath.Join(cwd, swaggerGenDir)
swaggerFilePathFull := filepath.Join(cwd, swaggerFilePath)
err = os.MkdirAll(swaggerGenDirFull, 0o755)
if err != nil {
return err
}
executable := "swagger"
args := []string{"generate", "server", "-t", swaggerGenDirFull, "-f", swaggerFilePathFull, "--exclude-main", "-A", "lookout"}
return run(executable, args...)
}
func run(executable string, args ...string) error {
cmd := exec.Command(executable, args...)
cmd.Env = os.Environ()
out, err := cmd.CombinedOutput()
if len(out) > 0 {
fmt.Println("OUTPUT:")
fmt.Println(string(out))
}
return err
}
func main() {
err := generateSwagger()
if err != nil {
log.WithError(err).Error("swagger generation failed")
os.Exit(1)
}
}