|
|
@ -41,13 +41,14 @@ func main() {
|
|
|
|
|
|
|
|
|
|
|
|
func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
|
|
|
func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
|
|
|
name := strings.ToLower(api.Service.Name)
|
|
|
|
name := strings.ToLower(api.Service.Name)
|
|
|
|
if strings.HasSuffix(name, "-api") {
|
|
|
|
|
|
|
|
name = strings.ReplaceAll(name, "-api", "")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
filename, err := format.FileNamingFormat(cfg.NamingFormat, name)
|
|
|
|
filename, err := format.FileNamingFormat(cfg.NamingFormat, name)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
configName := filename
|
|
|
|
|
|
|
|
if strings.HasSuffix(filename, "-api") {
|
|
|
|
|
|
|
|
filename = strings.ReplaceAll(filename, "-api", "")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return genFile(fileGenConfig{
|
|
|
|
return genFile(fileGenConfig{
|
|
|
|
dir: dir,
|
|
|
|
dir: dir,
|
|
|
@ -59,7 +60,7 @@ func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
|
|
|
builtinTemplate: mainTemplate,
|
|
|
|
builtinTemplate: mainTemplate,
|
|
|
|
data: map[string]string{
|
|
|
|
data: map[string]string{
|
|
|
|
"importPackages": genMainImports(rootPkg),
|
|
|
|
"importPackages": genMainImports(rootPkg),
|
|
|
|
"serviceName": api.Service.Name,
|
|
|
|
"serviceName": configName,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|