Skip to content

feat: Pass schema type/formats to runtime v1.2.0 to allow better parameter serialization#2256

Merged
jamietanna merged 2 commits intooapi-codegen:mainfrom
mromaszewicz:param-options
Feb 27, 2026
Merged

feat: Pass schema type/formats to runtime v1.2.0 to allow better parameter serialization#2256
jamietanna merged 2 commits intooapi-codegen:mainfrom
mromaszewicz:param-options

Conversation

@mromaszewicz
Copy link
Copy Markdown
Member

No description provided.

mromaszewicz and others added 2 commits February 26, 2026 14:17
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…g functions

Update all parameter binding and styling call sites across all server
templates and the client template to pass the OpenAPI schema Type and
Format through to the runtime library. This enables the runtime (v1.2.0+)
to correctly handle format: byte parameters by base64-encoding/decoding
the value, instead of incorrectly treating []byte as a generic []uint8
slice.

Changes:
- Add SchemaType() and SchemaFormat() helper methods to ParameterDefinition
- Update BindStyledParameterWithOptions calls in all 7 server templates
  (echo, chi, stdhttp, gin, gorilla, fiber, iris) to include Type/Format
- Replace BindQueryParameter with BindQueryParameterWithOptions in all 7
  server templates, passing Type/Format via options struct
- Replace StyleParamWithLocation with StyleParamWithOptions in client.tmpl,
  passing Type/Format via options struct
- Regenerate all test fixtures

Requires a minimum of runtime v1.2.0.

Closes #173
Closes oapi-codegen#2248

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mromaszewicz mromaszewicz requested a review from a team as a code owner February 26, 2026 22:52
@mromaszewicz
Copy link
Copy Markdown
Member Author

@greptileai

@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgithub.com/​gin-gonic/​gin@​v1.9.1 ⏵ v1.10.171 +1100100100100
Updatedgithub.com/​labstack/​echo/​v4@​v4.11.3 ⏵ v4.11.472 +1100100100100
Updatedgithub.com/​oapi-codegen/​runtime@​v1.1.0 ⏵ v1.2.098100100100100

View full report

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Feb 26, 2026

Greptile Summary

This PR passes OpenAPI schema type and format information to the runtime library's parameter binding functions, fixing incorrect handling of format: byte parameters.

Key Changes:

  • Added SchemaType() and SchemaFormat() helper methods to ParameterDefinition with proper nil safety checks
  • Updated all server templates (chi, echo, stdhttp, gin, gorilla, fiber, iris) to pass type/format to BindStyledParameterWithOptions and BindQueryParameterWithOptions
  • Updated client template to pass type/format to StyleParamWithOptions
  • Upgraded github.com/oapi-codegen/runtime from v1.1.0 to v1.2.0 to support the new options
  • Regenerated all test fixtures

Impact:
The runtime can now correctly base64-encode/decode format: byte parameters instead of incorrectly treating []byte as []uint8 slices. This fixes issues #173 and #2248.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured, consistently applied across all templates, and properly tested. The implementation includes appropriate nil checks, the dependency update aligns with the code changes, and all test fixtures have been regenerated successfully. This is a focused bug fix that addresses known issues without introducing breaking changes.
  • No files require special attention

Important Files Changed

Filename Overview
pkg/codegen/operations.go Added two helper methods (SchemaType, SchemaFormat) to extract OpenAPI schema metadata for parameters with proper nil checks
pkg/codegen/templates/chi/chi-middleware.tmpl Updated parameter binding calls to pass OpenAPI type/format information to runtime functions
pkg/codegen/templates/client.tmpl Updated client parameter styling calls to pass OpenAPI type/format information to runtime functions
pkg/codegen/templates/echo/echo-wrappers.tmpl Updated parameter binding calls to pass OpenAPI type/format information to runtime functions
examples/go.mod Updated runtime dependency to v1.2.0 to support new Type/Format parameter options
internal/test/go.mod Updated runtime dependency to v1.2.0 and other transitive dependencies

Last reviewed commit: 375bf71

@mromaszewicz mromaszewicz changed the title Param options feat: Pass schema type/formats to new runtime to allow better parameter serialization Feb 26, 2026
@mromaszewicz mromaszewicz changed the title feat: Pass schema type/formats to new runtime to allow better parameter serialization feat: Pass schema type/formats to runtime v1.2.0 to allow better parameter serialization Feb 26, 2026
@mromaszewicz mromaszewicz added the notable changes Used for release notes to highlight these more highly label Feb 26, 2026
@jamietanna jamietanna added this to the v2.6.0 milestone Feb 27, 2026
@jamietanna jamietanna added the enhancement New feature or request label Feb 27, 2026
@jamietanna jamietanna merged commit 15fc536 into oapi-codegen:main Feb 27, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request notable changes Used for release notes to highlight these more highly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants