Skip to content

Commit 5f4f888

Browse files
mromaszewiczclaude
andcommitted
fix: clean up and test parameter binding
Audit and fix parameter binding in all 8 server code generation templates (Echo v4, Echo v5, Chi, Gin, Gorilla, Iris, Fiber, stdhttp) to ensure consistent, correct handling of path, query, header, and cookie parameters across all OpenAPI styles and types. Template fixes: - Add missing ParamLocation to path params (Gin, Fiber, Gorilla) and cookie params (Chi, Gin, Fiber, Gorilla, stdhttp) so the runtime applies correct URL escaping per location - Add missing Type/Format fields to Echo v5 path, header, and cookie params, and upgrade its query binding to BindQueryParameterWithOptions - Fix required deepObject query params rejected by a spurious pre-check in Chi, Gin, Gorilla, Fiber, and stdhttp templates - Fix Gin, Iris, and Fiber using query param getters instead of path param getters for content-based (passthrough/JSON) path parameters - Fix Iris cookie params calling nonexistent ctx.Cookie() (now ctx.GetCookie()) and query params calling ctx.QueryParam() (now ctx.URLParam()) - Fix Fiber cookie params redeclaring var in a loop (now block-scoped) - Fix Fiber not URL-decoding path param values for passthrough/JSON - Add _ = err to suppress unused variable when only passthrough path params exist (Chi, Gin, Gorilla, Iris, Fiber, stdhttp) Multi-router parameter roundtrip test: - New test infrastructure under internal/test/parameters/ with per-router subdirectories (echo, chi, gin, gorilla, iris, fiber, stdhttp) plus a shared client package - Each router's server echoes received parameters back as JSON; the shared testImpl sends requests via the generated client and verifies the JSON response matches the original values - Generated files isolated in gen/ subdirectories so go generate works even when generated code has compilation errors - Echo v5 in its own module (Go 1.25+) with version-guarded Makefile - Covers all OpenAPI parameter styles (simple, label, matrix, form, deepObject) x types (primitive, array, object) x explode flags across path, query, header, and cookie locations Skipped tests pending external changes: - spaceDelimited and pipeDelimited query styles: runtime does not yet support binding these styles (oapi-codegen/runtime#116) - stdhttp roundtrip: stdlib ServeMux cannot register path wildcards starting with a digit like {1param} (#2306) Closes: #777, #1752 Obsoletes: #1751, #2062 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c322d1a commit 5f4f888

File tree

73 files changed

+16796
-1129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+16796
-1129
lines changed

examples/petstore-expanded/echo-v5/api/petstore-server.gen.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/test/cookies/cookies.gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/test/issues/issue-1378/bionicle/bionicle.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/test/issues/issue-1378/fooservice/fooservice.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/test/outputoptions/name-normalizer/to-camel-case-with-additional-initialisms/name_normalizer.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/test/outputoptions/name-normalizer/to-camel-case-with-digits/name_normalizer.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/test/outputoptions/name-normalizer/to-camel-case-with-initialisms/name_normalizer.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/test/outputoptions/name-normalizer/to-camel-case/name_normalizer.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/test/outputoptions/name-normalizer/unset/name_normalizer.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)