From 555f453ffc60697e2e341c8a111b8b54eb5ffb69 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Sun, 8 Feb 2026 22:50:29 -0500 Subject: [PATCH] feat: Support `[]string` return type in gen-iterators.go Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/gen-iterators.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/github/gen-iterators.go b/github/gen-iterators.go index f0fee620c1f..59b0da2838c 100644 --- a/github/gen-iterators.go +++ b/github/gen-iterators.go @@ -126,6 +126,7 @@ type method struct { // This is needed for methods that internally unmarshal a wrapper struct // even though they return a slice. var customTestJSON = map[string]string{ + // Uncomment in #3978: "ListAllTopics": `{"names": []}`, "ListUserInstallations": `{"installations": []}`, } @@ -317,13 +318,16 @@ func (t *templateData) processMethods(f *ast.File) error { logf("WARNING: clientField is 's' for %s.%s (recvType=%s)", recvType, fd.Name.Name, recType) } - testJSON := "[]" + testJSON, emptyReturnValue := "[]", "{}" if val, ok := customTestJSON[fd.Name.Name]; ok { testJSON = val } - testJSON1 := strings.ReplaceAll(testJSON, "[]", "[{},{},{}]") // Call 1 - return 3 items - testJSON2 := strings.ReplaceAll(testJSON, "[]", "[{},{},{},{}]") // Call 1 part 2 - return 4 items - testJSON3 := strings.ReplaceAll(testJSON, "[]", "[{},{}]") // Call 2 - return 2 items + if eltType == "string" { + emptyReturnValue = `""` + } + testJSON1 := strings.ReplaceAll(testJSON, "[]", fmt.Sprintf("[%v,%[1]v,%[1]v]", emptyReturnValue)) // Call 1 - return 3 items + testJSON2 := strings.ReplaceAll(testJSON, "[]", fmt.Sprintf("[%v,%[1]v,%[1]v,%[1]v]", emptyReturnValue)) // Call 1 part 2 - return 4 items + testJSON3 := strings.ReplaceAll(testJSON, "[]", fmt.Sprintf("[%v,%[1]v]", emptyReturnValue)) // Call 2 - return 2 items m := &method{ RecvType: recType,