ogen-go / ogen

OpenAPI v3 code generator for go
https://ogen.dev
Apache License 2.0
1.29k stars 75 forks source link

format: support formatting time.Time as RFC3339Nano #1063

Open anuraaga opened 11 months ago

anuraaga commented 11 months ago

Description

Currently, date-time format uses RFC3339. It would be nice if it were possible to format is RFC3339Nano, perhaps by adding a custom date-time-nano format, or adding a generator option. While there is naturally a limit to how many bespoke formats this generator can support, I believe this one is particularly helpful because the default JSON marshaling of Golang for time.Time is actually RFC3339Nano, which means that there is some friction in migrating existing codebases to ogen which may be using default JSON marshaling, even via some framework like Gin, and having no way without CustomFormat to reproduce the same behavior with ogen.

antonyc commented 10 months ago

Could anyone please have a look at that?

anuraaga commented 6 months ago

Updating ogen after a while and realized that CustomFormat support was removed in #1090. It's too bad since it seemed like a useful feature in certain situations, but specifically for this now it seems there may be no way to reproduce the standard library marshaling of time.Time with ogen. The format idea seems nice too, would it be a reasonable feature to add?