Nswag CLI generates incorrect DateTime type for C# clients
See original GitHub issueHi,
I have below class definition:
public class SomeClass
{
public DateTime SomeDateTime { get; set; }
}
After generating C# client with below command:
nswag openapi2csclient /runtime:NetCore31 /dateTimeType: 'System.DateTime'
(Other configuration options like URL address, output file name etc. have been ommitted for brevity).
I get an auto-generated client with method definitions containing DateTimeOffset
class:
[Newtonsoft.Json.JsonProperty("someDateTime", Required = Newtonsoft.Json.Required.Always)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public System.DateTimeOffset SomeDateTime { get; set; }
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
NSwagStudio Generated C# Client Offsets Dates
The DateTime from the serializer will have a DateTimeKind of DateTimeKind.Utc . Unfortunately, comparing that with another DateTime (even of ...
Read more >Generate TypeScript and C# clients with NSwag based on ...
Learn how to generate TypeScript and C# API clients with NSwag to reduce your workload when building a project.
Read more >Maintaining API Clients With NSwag Model Generation
Using this CLI, the following command successfully generated the C# models we needed from the OpenAPI models defined in the spec. Command:
Read more >NSwag – Emil's Lost & Found Archive - Meadow
Net DateTime types for dates rather than DateTimeOffset which NSwag for some reason seems to default to. /GenerateExceptionClasses:false and / ...
Read more >Auto Generated .NET API Clients using NSwag and ...
This article shows how auto generated code for a C# HTTP API client could be created using Swagger and NSwag . The API...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@RicoSuter how do you do that via the command line (as this bug still exists and is technically two bugs)?
You can configure this: