Skip to content

fix: getting cookie in fiber middleware#2062

Merged
mromaszewicz merged 9 commits intooapi-codegen:mainfrom
YATAHAKI:fix/getting_cookie_in_fiber_middleware
Mar 23, 2026
Merged

fix: getting cookie in fiber middleware#2062
mromaszewicz merged 9 commits intooapi-codegen:mainfrom
YATAHAKI:fix/getting_cookie_in_fiber_middleware

Conversation

@YATAHAKI
Copy link
Copy Markdown
Contributor

Closes: #1752

Related to: #1751

@YATAHAKI YATAHAKI requested a review from a team as a code owner August 19, 2025 10:48
@kusari-inspector
Copy link
Copy Markdown

kusari-inspector bot commented Aug 19, 2025

Kusari Inspector

Kusari Analysis Results:

Proceed with these changes

✅ No Flagged Issues Detected
All values appear to be within acceptable risk parameters.

No pinned version dependency changes, code issues or exposed secrets detected!

Note

View full detailed analysis result for more information on the output and the checks that were run.


@kusari-inspector rerun - Trigger a re-analysis of this PR
@kusari-inspector feedback [your message] - Send feedback to our AI and team
See Kusari's documentation for setup and configuration.
Commit: 0f5f85b, performed at: 2025-09-14T10:06:23Z

Found this helpful? Give it a 👍 or 👎 reaction!

@kusari-inspector
Copy link
Copy Markdown

Kusari PR Analysis rerun based on - 6dbf62a performed at: 2025-08-20T12:13:56Z - link to updated analysis

@kusari-inspector
Copy link
Copy Markdown

Kusari PR Analysis rerun based on - 0f5f85b performed at: 2025-09-14T10:06:39Z - link to updated analysis

var cookie string

if cookie = c.Cookies("{{.ParamName}}"); cookie == "" {
if cookie = c.Cookies("{{.ParamName}}"); cookie != "" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, nice find.

@mromaszewicz mromaszewicz added the bug Something isn't working label Mar 23, 2026
@mromaszewicz mromaszewicz merged commit 28e3bc1 into oapi-codegen:main Mar 23, 2026
18 checks passed
mromaszewicz added a commit to mromaszewicz/oapi-codegen that referenced this pull request Mar 27, 2026
…uters

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} (oapi-codegen#2306)

Closes: oapi-codegen#777, oapi-codegen#1752
Obsoletes: oapi-codegen#1751, oapi-codegen#2062

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mromaszewicz added a commit to mromaszewicz/oapi-codegen that referenced this pull request Mar 27, 2026
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} (oapi-codegen#2306)

Closes: oapi-codegen#777, oapi-codegen#1752
Obsoletes: oapi-codegen#1751, oapi-codegen#2062

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mromaszewicz added a commit to mromaszewicz/oapi-codegen that referenced this pull request Mar 27, 2026
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} (oapi-codegen#2306)

Closes: oapi-codegen#777, oapi-codegen#1752
Obsoletes: oapi-codegen#1751, oapi-codegen#2062

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mromaszewicz added a commit to mromaszewicz/oapi-codegen that referenced this pull request Mar 27, 2026
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} (oapi-codegen#2306)

Closes: oapi-codegen#777, oapi-codegen#1752
Obsoletes: oapi-codegen#1751, oapi-codegen#2062

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cookies will never be used when generating a fiber server

3 participants