From 530dd79e3fde27970567ec27931641a4afe6c555 Mon Sep 17 00:00:00 2001 From: fondoger Date: Thu, 16 Feb 2023 16:40:18 +0800 Subject: [PATCH] Fix bug in dart api gen: path parameter is not replaced --- tools/goctl/api/dartgen/util.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/goctl/api/dartgen/util.go b/tools/goctl/api/dartgen/util.go index 907667c9..e40c9c56 100644 --- a/tools/goctl/api/dartgen/util.go +++ b/tools/goctl/api/dartgen/util.go @@ -185,7 +185,8 @@ func extractPositionalParamsFromPath(route spec.Route) string { var params []string for _, member := range ds.GetTagMembers(pathTagKey) { - params = append(params, fmt.Sprintf("%s %s", member.Type.Name(), getPropertyFromMember(member))) + dartType := member.Type.Name() + params = append(params, fmt.Sprintf("%s %s", dartType, getPropertyFromMember(member))) } return strings.Join(params, ", ") @@ -199,7 +200,8 @@ func makeDartRequestUrlPath(route spec.Route) string { } for _, member := range ds.GetTagMembers(pathTagKey) { - path = strings.ReplaceAll(path, ":"+pathTagKey, "${"+getPropertyFromMember(member)+"}") + paramName := member.Tags()[0].Name + path = strings.ReplaceAll(path, ":"+paramName, "${"+getPropertyFromMember(member)+"}") } return `"` + path + `"`