-
Notifications
You must be signed in to change notification settings - Fork 0
/
generators.go
67 lines (60 loc) · 2.49 KB
/
generators.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package generators
import (
"github.com/specgen-io/specgen/v2/goven/generator"
"github.com/specgen-io/specgen/v2/goven/golang/client"
"github.com/specgen-io/specgen/v2/goven/golang/models"
"github.com/specgen-io/specgen/v2/goven/golang/service"
"github.com/specgen-io/specgen/v2/goven/spec"
)
var JsonmodeGoValues = []string{"strict", "nonstrict"}
var Models = generator.Generator{
"models-go",
"Go Models",
"Generate Go models source code",
[]generator.GeneratorArg{
{Arg: generator.ArgSpecFile, Required: true},
{Arg: generator.ArgJsonmode, Required: false, Values: JsonmodeGoValues},
{Arg: generator.ArgModuleName, Required: true},
{Arg: generator.ArgGeneratePath, Required: true},
},
func(specification *spec.Spec, params generator.GeneratorArgsValues) *generator.Sources {
return models.GenerateModels(specification, params[generator.ArgJsonmode], params[generator.ArgModuleName], params[generator.ArgGeneratePath])
},
}
var Client = generator.Generator{
"client-go",
"Go Client",
"Generate Go client source code",
[]generator.GeneratorArg{
{Arg: generator.ArgSpecFile, Required: true},
{Arg: generator.ArgJsonmode, Required: false, Values: JsonmodeGoValues},
{Arg: generator.ArgModuleName, Required: true},
{Arg: generator.ArgGeneratePath, Required: true},
},
func(specification *spec.Spec, params generator.GeneratorArgsValues) *generator.Sources {
return client.GenerateClient(specification, params[generator.ArgJsonmode], params[generator.ArgModuleName], params[generator.ArgGeneratePath])
},
}
var ServerGoValues = []string{"vestigo", "httprouter", "chi"}
var Service = generator.Generator{
"service-go",
"Go Service",
"Generate Go service source code",
[]generator.GeneratorArg{
{Arg: generator.ArgSpecFile, Required: true},
{Arg: generator.ArgJsonmode, Required: false, Values: JsonmodeGoValues},
{Arg: generator.ArgServer, Required: true, Values: ServerGoValues},
{Arg: generator.ArgModuleName, Required: true},
{Arg: generator.ArgSwaggerPath, Required: false},
{Arg: generator.ArgGeneratePath, Required: true},
{Arg: generator.ArgServicesPath, Required: false},
},
func(specification *spec.Spec, params generator.GeneratorArgsValues) *generator.Sources {
return service.GenerateService(specification, params[generator.ArgJsonmode], params[generator.ArgServer], params[generator.ArgModuleName], params[generator.ArgSwaggerPath], params[generator.ArgGeneratePath], params[generator.ArgServicesPath])
},
}
var All = []generator.Generator{
Models,
Client,
Service,
}