-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (32 loc) · 1.24 KB
/
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
// package main is the entry point for the gogenswagger
package main
import (
"flag"
"log"
"github.com/Mussabaheen/gogenswagger/internals/template"
"github.com/Mussabaheen/gogenswagger/pkg/language"
"github.com/Mussabaheen/gogenswagger/pkg/swagger"
)
var (
fileExtensionUsage = "Specify the language extension, currently supported languages js and go"
swaggerFileUsage = "Specify the Swagger JSON file path"
outputPathUsage = "Specify the path for generated test packages"
)
func main() {
// fileExtension represents the arg with flag -l
fileExtension := flag.String("language", "go", fileExtensionUsage)
// swaggerFile represents the arg with flag -s
swaggerFile := flag.String("json", "", swaggerFileUsage)
// outputPath represents the arg with flat -o
outputPath := flag.String("output", "./generated", outputPathUsage)
flag.Parse()
if *swaggerFile == "" {
log.Fatalf("Swagger json not provided, please provide Swagger JSON file with -s flag")
}
language := language.NewLangugae(*fileExtension)
tmplPath, fileExtn := language.Select()
fetch := swagger.NewSwagger(*swaggerFile)
jsonSwagger := fetch.JSONParser()
testGenerator := template.NewTemplate(tmplPath, *outputPath)
testGenerator.GenerateTestFiles(jsonSwagger, fileExtn)
}