Skip to content

Date type XML marshalling - #58

Closed
Reilley64 wants to merge 1 commit into
oapi-codegen:mainfrom
Reilley64:main
Closed

Reilley64 wants to merge 1 commit into
oapi-codegen:mainfrom
Reilley64:main

Conversation

@Reilley64

Copy link
Copy Markdown

No description provided.

@Reilley64
Reilley64 requested a review from a team as a code owner January 14, 2025 00:53
@Reilley64 Reilley64 closed this by deleting the head repository Nov 26, 2025
jusabe-kreditz added a commit to jusabe-kreditz/runtime that referenced this pull request Sep 14, 2026
Date defines UnmarshalText, which parses the "2006-01-02" DateFormat, but
has no MarshalText, so it inherits time.Time's RFC 3339 one. Every codec
that pairs encoding.TextMarshaler with encoding.TextUnmarshaler therefore
writes a Date it cannot read back:

    xml.Marshal   -> <date>2019-04-01T00:00:00Z</date>
    xml.Unmarshal -> parsing time "2019-04-01T00:00:00Z": extra text: "T00:00:00Z"

Format with DateFormat instead, matching MarshalJSON, String and
UnmarshalText, and matching the method set types.Duration already carries.

This also resolves the XML round trip that oapi-codegen#58 addressed with MarshalXML
and UnmarshalXML, without needing the encoding/xml import.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant