|
|
@ -67,11 +67,11 @@ suspend fun apiRequest(
|
|
|
|
eventually?.invoke()
|
|
|
|
eventually?.invoke()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
`
|
|
|
|
apiTemplate = `package {{with .Info}}{{.Title}}{{end}}
|
|
|
|
apiTemplate = `package {{with .Info}}{{.Desc}}{{end}}
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.gson.Gson
|
|
|
|
import com.google.gson.Gson
|
|
|
|
|
|
|
|
|
|
|
|
object Api{
|
|
|
|
object {{with .Info}}{{.Title}}{{end}}{
|
|
|
|
{{range .Types}}
|
|
|
|
{{range .Types}}
|
|
|
|
data class {{.Name}}({{$length := (len .Members)}}{{range $i,$item := .Members}}
|
|
|
|
data class {{.Name}}({{$length := (len .Members)}}{{range $i,$item := .Members}}
|
|
|
|
val {{with $item}}{{lowCamelCase .Name}}: {{parseType .Type}}{{end}}{{if ne $i (add $length -1)}},{{end}}{{end}}
|
|
|
|
val {{with $item}}{{lowCamelCase .Name}}: {{parseType .Type}}{{end}}{{if ne $i (add $length -1)}},{{end}}{{end}}
|
|
|
@ -120,8 +120,10 @@ func genBase(dir, pkg string, api *spec.ApiSpec) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func genApi(dir, pkg string, api *spec.ApiSpec) error {
|
|
|
|
func genApi(dir, pkg string, api *spec.ApiSpec) error {
|
|
|
|
path := filepath.Join(dir, strcase.ToCamel(api.Info.Title+"Api")+".kt")
|
|
|
|
name := strcase.ToCamel(api.Info.Title + "Api")
|
|
|
|
api.Info.Title = pkg
|
|
|
|
path := filepath.Join(dir, name+".kt")
|
|
|
|
|
|
|
|
api.Info.Title = name
|
|
|
|
|
|
|
|
api.Info.Desc = pkg
|
|
|
|
|
|
|
|
|
|
|
|
e := os.MkdirAll(dir, 0755)
|
|
|
|
e := os.MkdirAll(dir, 0755)
|
|
|
|
if e != nil {
|
|
|
|
if e != nil {
|
|
|
|