You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error when unmarshaling types.Date query param #21
I am encountering an issue when binding date query parameters in a Gin-Gonic application. The problem arises when using oapi-codegen to generate models that include a date query parameter.
Steps to Reproduce
OpenAPI Specification: I defined a date query parameter in my OpenAPI specification as follows:
- name: date_fromin: queryschema:
type: stringformat: date
Generated Go Model: Using oapi-codegen, the above specification generates a Go struct resembling:
Error Received: invalid character '-' after top-level value
Expected Behavior
I expect the date_from query parameter to be bound successfully to the Params struct without errors, parsing the date string correctly.
Actual Behavior
The binding process fails with an error indicating an issue with the '-' character in the date string, which suggests a possible problem with how the date string is being parsed or handled during the binding process.
The runtime bug was fixed in #93, released in v1.2.0 — generated servers bind types.Date query params correctly.
Binding via Gin's native c.BindQuery is outside this runtime's control; on gin ≥ v1.12.0 it works by adding parser=encoding.TextUnmarshaler to the form tag, which users can inject per-field today with x-oapi-codegen-extra-tags (its form: key replaces the default tag wholesale).
Activity
fix: bind Date and Time query params as scalar values (oapi-codegen#21)
fix: bind Date and Time query params as scalar values (#21) (#93)
mromaszewicz commentedon Jul 12, 2026
The runtime bug was fixed in #93, released in v1.2.0 — generated servers bind types.Date query params correctly.
Binding via Gin's native c.BindQuery is outside this runtime's control; on gin ≥ v1.12.0 it works by adding parser=encoding.TextUnmarshaler to the form tag, which users can inject per-field today with x-oapi-codegen-extra-tags (its form: key replaces the default tag wholesale).