Default value for DateTime: shouldn't it contain a timezone offset? #3856
WolfgangHG
started this conversation in
General
Replies: 1 comment 2 replies
-
All we do is this: The value will get converted based on the default JSON serialization rules for |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a model class with this DateTime default:
I picked this syntax from WinForms designer properties - there it is the way to make the designer not serialize a control property if the current value matches the default value.
In the generated json file, a "T" is added, so you probably do something special already.
But according to the spec at https://swagger.io/docs/specification/v3_0/data-models/data-types/#strings, it should be the date-time notation as defined by RFC 3339, section 5.6.
So, here either "Z" or "+00:00" is missing. A valid timezone cannot be chosen I think.
I ran into this problem when working on default value handling in Kiota - parsing of the datetime value failed for some client languages (e.g. Java or PHP)
A sample model file can be found in https://github.com/WolfgangHG/Swashbuckle_Discussion3709/ (used for a previous discussion) - start the project using the launch profile "WebApiSwaggerVersion".
Beta Was this translation helpful? Give feedback.
All reactions