Cannot use non-string Date Time type with Interface DTOs
See original GitHub issueIf you configure NSwag like so:
Then call a method that returns a date-time
or date
, the field that should contain a moment
will just contain a string.
If you use DTO Type Style: Class
, everything works fine as the init
method on the generated class converts it.
Is this something we should handle? Or is this why you should be using Type Style: Class
instead?
(I expect the same bug happens with Date Time type: Date, but haven’t tested)
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Cannot use non-string Date Time type with Interface DTOs
Yes, if you choose interface the response is provided as-is, no conversion happens. This is why the type class exists in the first...
Read more >Can't Give Dto Reference to Service Interface
I want to use Dtos to transfer data to service.I tried putting it in the business layer, but there is a problem. My...
Read more >Handling date fields in JSON with Typescript
A DTO will have string dates because this is what JSON supports. ... You can't pass types as parameters because they are removed...
Read more >Interfaces vs concrete types in DTOs and response classes
Normally always use interfaces instead of concrete types. Every time you add an interface, you add another type and you create a level...
Read more >DTO - A typescript utility type
Dto (Data Transfer Object) is a TypeScript utility type that can be used to represent an object that is going "over the wire"....
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
Will do soon 😃 Been a busy week. Would have been much busier without NSwag though!
On Fri, Jan 18, 2019 at 2:13 AM Rico Suter notifications@github.com wrote:
Looks like that would be a third option besides
interface
andclass
… please create a new issue in http://njsonschema.org