-
-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type: date format is not formatted correctly in c# #491
Comments
Figured out the typescript version, but I'm not sure how to implement it for c#, some help or advice here would be greatly appreciated. Thanks! |
I dont like to add more helper classes to the output (i.e. DateFormatConverter) but it seems that this is the only solution. The question is whether we generate this as a global type (potential name collisions) or as inline time in each class (more code, repetitions). |
We may need to do it in each class, otherwise if they generate multiple
clients in the same project we’ll cause a collision :(
…On Mon, 2 Oct 2017 at 6:45 PM, Rico Suter ***@***.***> wrote:
I dont like to add more helper classes to the output (i.e.
DateFormatConverter) but it seems that this is the only solution. The
question is whether we generate this as a global type (potential name
collisions) or as inline time in each class (more code, repetitions).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#491 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAX_ftfKBtq_OaVeK-an-IFr7yqNcbzcks5soHhfgaJpZM4PqJ7M>
.
|
Yes, this is exactly the problem (I think its a rare case, because it only happens when generating multiple clients from multiple swagger specs). I still prefer the "single utility class" option because we already have this problem with the JsonInheritanceConverter. However we should add the option GenerateDateFormatConverter (default: true) so that you can disable the generation for all but one generation (we also have GenerateJsonInheritanceConverter). This way it works the same for all these utility classes. What do you think? |
Ah yeah, that seems like a good way to do it. (Reminder to self: |
The actual class is rendered in FileTemplate.tt |
When a
"type": "date"
property is present in a schema we can generate a DateTime or DateTimeOffset field.However, when when serializing this field it is not turned in to a date, it is turned in to a dateTime.
ref: https://swagger.io/specification/#document-structure-12
date should be a full-date, which is
yyyy-MM-dd
in c#.To fix this, you can add
[Newtonsoft.Json.JsonConverter(typeof(DateFormatConverter))]
to the Property and define that converter as:Trying to figure out how to fix this myself, but... there is a lot of code in here :)
The text was updated successfully, but these errors were encountered: