CSharpGeneratorSettings is defaulting to use System.DateTimeOffset for date formats and System.TimeSpan for time formats instead of the newSystem.DateOnly and System.TimeOnly types.
The ability to override the types used for these formats exists with the following flags, but there exists another issue which prevents this from working.
I don't know what the solution to this should be; obviously changing this default would be a breaking change and it can't be done without also exposing or modifying other functionality around this formatter.
For now, we are generating the clients using those flags, but removing the DateFormatConverter and associated attributes in our generation script.
CSharpGeneratorSettings is defaulting to use
System.DateTimeOffset
fordate
formats andSystem.TimeSpan
fortime
formats instead of the newSystem.DateOnly
andSystem.TimeOnly
types.https://github.com/RicoSuter/NJsonSchema/blob/ed250a8b9c4f86a4da40cf0061cf0172cdea0449/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs#L22
https://github.com/RicoSuter/NJsonSchema/blob/ed250a8b9c4f86a4da40cf0061cf0172cdea0449/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs#L24
The ability to override the types used for these formats exists with the following flags, but there exists another issue which prevents this from working.
The
DateFormatConverter
assumes the time is aSystem.DateTime
and therefore will throw an exception upon deserialization.https://github.com/RicoSuter/NJsonSchema/blob/ed250a8b9c4f86a4da40cf0061cf0172cdea0449/src/NJsonSchema.CodeGeneration.CSharp/Templates/DateFormatConverter.liquid#L2-L29
There is also no ability to disable this from being generated because it only checks if the type starts with
System.Date
unfortunately...https://github.com/RicoSuter/NJsonSchema/blob/ed250a8b9c4f86a4da40cf0061cf0172cdea0449/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs#L148
I don't know what the solution to this should be; obviously changing this default would be a breaking change and it can't be done without also exposing or modifying other functionality around this formatter.
For now, we are generating the clients using those flags, but removing the
DateFormatConverter
and associated attributes in our generation script.