From 8c31525378c1c32103d1f14d6dd8fecfa0094745 Mon Sep 17 00:00:00 2001 From: zhoumingji Date: Sat, 4 Mar 2023 11:39:29 +0800 Subject: [PATCH] Fix bug in dartgen: Increase the processing logic when route.RequestType is empty --- tools/goctl/api/dartgen/genapi.go | 2 +- tools/goctl/api/dartgen/util.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/goctl/api/dartgen/genapi.go b/tools/goctl/api/dartgen/genapi.go index aec5aa55..c99e25bb 100644 --- a/tools/goctl/api/dartgen/genapi.go +++ b/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, diff --git a/tools/goctl/api/dartgen/util.go b/tools/goctl/api/dartgen/util.go index e40c9c56..714d844b 100644 --- a/tools/goctl/api/dartgen/util.go +++ b/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