Browse Source

Fix bug in dartgen: Increase the processing logic when route.RequestType is empty

zhoumingji 2 years ago
parent
commit
97ada59175
2 changed files with 5 additions and 1 deletions
  1. 1 1
      tools/goctl/api/dartgen/genapi.go
  2. 4 0
      tools/goctl/api/dartgen/util.go

+ 1 - 1
tools/goctl/api/dartgen/genapi.go

@@ -38,7 +38,7 @@ import '../data/{{with .Service}}{{.Name}}{{end}}.dart';
 ///
 /// request: {{with .RequestType}}{{.Name}}{{end}}
 /// response: {{with .ResponseType}}{{.Name}}{{end}}
-Future {{normalizeHandlerName .Handler}}( 
+Future {{normalizeHandlerName .Handler}}(
 	{{if hasUrlPathParams $Route}}{{extractPositionalParamsFromPath $Route}},{{end}}
 	{{if ne .Method "get"}}{{with .RequestType}}{{.Name}} request,{{end}}{{end}}
     {Function({{with .ResponseType}}{{.Name}}{{end}})? ok,

+ 4 - 0
tools/goctl/api/dartgen/util.go

@@ -194,6 +194,10 @@ func extractPositionalParamsFromPath(route spec.Route) string {
 
 func makeDartRequestUrlPath(route spec.Route) string {
 	path := route.Path
+	if route.RequestType == nil {
+		return `"` + path + `"`
+	}
+
 	ds, ok := route.RequestType.(spec.DefineStruct)
 	if !ok {
 		return path