Skip to content

fix(bind): honor OpenAPI date-time format tags - #3145

Draft
vishr with Copilot wants to merge 3 commits into
masterfrom
copilot/resolve-format-tag-conflict
Draft

vishr with Copilot wants to merge 3 commits into
masterfrom
copilot/resolve-format-tag-conflict

Conversation

Copilot AI commented Oct 2, 2026 •

Copy link
Copy Markdown

Adding Swag's format:"date-time" tag to a time.Time field made Echo interpret the OpenAPI name as a Go time layout, rejecting otherwise valid RFC3339 input.

This change recognizes the two OpenAPI format names for time.Time and *time.Time fields in path, query, header, and form binding:

  • date-time uses the same standard-library text decoder as an untagged time.Time, accepting RFC3339 timestamps with Z or a numeric offset.
  • date-time-local accepts 2006-01-02T15:04:05 with optional fractional seconds and rejects timezone suffixes. Parsing assigns UTC, consistent with Echo's existing custom layouts that omit a timezone. This is an Echo parsing policy; the input itself does not specify UTC.

The formats have distinct semantics in the OpenAPI registry. Other format values continue to be Go layouts. JSON/XML decoding and custom unmarshaler dispatch retain their existing behavior; slice elements retain their existing format-tag behavior.

Validation:

  • go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
  • go vet ./...
  • Regression cases cover both formats, scalar and pointer fields, all five affected binding sources, fractional seconds, preserved offsets, invalid dates, missing/forbidden timezones, JSON decoding, and custom types. Existing custom-layout and untagged binding tests also pass.

Fixes #3107

Copilot AI linked an issue Oct 2, 2026 that may be closed by this pull request
Co-authored-by: vishr <314036+vishr@users.noreply.github.com>
Copilot AI changed the title [WIP] Resolve format tag conflicts with swag Support OpenAPI date-time formats in time binding Oct 2, 2026
Copilot AI requested a review from vishr October 2, 2026 18:03
@vishr vishr changed the title Support OpenAPI date-time formats in time binding fix(bind): honor OpenAPI date-time format tags Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

format tag conflicts with swag

2 participants