From 2541105d8d142b2294fcad9b6c37787c45f31548 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 01:08:26 +0000 Subject: [PATCH 1/2] fix: set a named array query parameter in the generated params test ParamSamples skipped an array parameter whose schema is a $ref to a named array, such as Modules, so TestClient_Params never checked that the client sends it. A named slice takes the same composite literal, so sample it like an unnamed one. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y --- ir/sample.go | 5 ++-- testdata/golden/pkg/golden/client.gen_test.go | 24 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ir/sample.go b/ir/sample.go index 73a7c8b4..b46f6044 100644 --- a/ir/sample.go +++ b/ir/sample.go @@ -4,7 +4,6 @@ import ( "cmp" "slices" "strconv" - "strings" ) // ParamSample is a value a generated test sets a parameter to, and what the request must then carry for it. @@ -18,7 +17,7 @@ type ParamSample struct { // ParamSamples are the query and header parameters of op a generated test can set and then find in the request, each // with a value to set it to. A query parameter may be a scalar or an array of scalars, which the test sets to one -// item, the same on the wire in every style; a header parameter must be a scalar. Objects, maps and values with no +// item, the same on the wire in every style, whether the array is named or not; a header parameter must be a scalar. Objects, maps and values with no // plain text form, such as times, are left out. func (doc Document) ParamSamples(op Operation) []ParamSample { var samples []ParamSample @@ -29,7 +28,7 @@ func (doc Document) ParamSamples(op Operation) []ParamSample { switch { case p.Props != nil, p.MapValue != nil: case p.Item != nil: - if lit, wire, ok := doc.scalarSample(*p.Item, len(samples)); ok && strings.HasPrefix(p.Type, "[]") { + if lit, wire, ok := doc.scalarSample(*p.Item, len(samples)); ok { samples = append(samples, ParamSample{Param: p, Literal: p.Type + "{" + lit + "}", Wire: wire}) } default: diff --git a/testdata/golden/pkg/golden/client.gen_test.go b/testdata/golden/pkg/golden/client.gen_test.go index 0536d487..bbcb6484 100644 --- a/testdata/golden/pkg/golden/client.gen_test.go +++ b/testdata/golden/pkg/golden/client.gen_test.go @@ -2315,14 +2315,15 @@ func TestClient_Params(t *testing.T) { } _ = c.QueryStyles(t.Context(), 0, QueryStylesParams{ - Csv: []int{2}, - Spaced: []string{""}, - Piped: []string{""}, - Next: "next", - Paths: []string{""}, - Cells: []string{""}, - Level: LevelThree, - Ratio: 9.5, + Csv: []int{2}, + Spaced: []string{""}, + Piped: []string{""}, + Next: "next", + Paths: []string{""}, + Cells: []string{""}, + Modules: Modules{ModuleSummaryDetail}, + Level: LevelThree, + Ratio: 10.5, }) if got == nil { @@ -2347,11 +2348,14 @@ func TestClient_Params(t *testing.T) { if v := got.URL.Query().Get("cells"); v != "" { t.Errorf("query %s: got %q, want %q", "cells", v, "") } + if v := got.URL.Query().Get("modules"); v != "summaryDetail" { + t.Errorf("query %s: got %q, want %q", "modules", v, "summaryDetail") + } if v := got.URL.Query().Get("level"); v != "3" { t.Errorf("query %s: got %q, want %q", "level", v, "3") } - if v := got.URL.Query().Get("ratio"); v != "9.5" { - t.Errorf("query %s: got %q, want %q", "ratio", v, "9.5") + if v := got.URL.Query().Get("ratio"); v != "10.5" { + t.Errorf("query %s: got %q, want %q", "ratio", v, "10.5") } }) } From 093c2699509ef8e3b196264bb358fbfc27d92ee2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 01:08:52 +0000 Subject: [PATCH 2/2] chore: rewrap the ParamSamples comment Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y --- ir/sample.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ir/sample.go b/ir/sample.go index b46f6044..4557a519 100644 --- a/ir/sample.go +++ b/ir/sample.go @@ -16,9 +16,9 @@ type ParamSample struct { } // ParamSamples are the query and header parameters of op a generated test can set and then find in the request, each -// with a value to set it to. A query parameter may be a scalar or an array of scalars, which the test sets to one -// item, the same on the wire in every style, whether the array is named or not; a header parameter must be a scalar. Objects, maps and values with no -// plain text form, such as times, are left out. +// with a value to set it to. A query parameter may be a scalar or an array of scalars, named or not, which the test +// sets to one item, the same on the wire in every style; a header parameter must be a scalar. Objects, maps and values +// with no plain text form, such as times, are left out. func (doc Document) ParamSamples(op Operation) []ParamSample { var samples []ParamSample