question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use non-string Date Time type with Interface DTOs

See original GitHub issue

If you configure NSwag like so: image

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:closed
  • Created 6 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
simeylacommented, Jan 19, 2019

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:

Interesing idea - can you create a new issue in NJsonSchema with all this text? 😃 and reference this issue here… otherwise we will lose track of it because the issue is closed…

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RSuter/NSwag/issues/980#issuecomment-455495790, or mute the thread https://github.com/notifications/unsubscribe-auth/ADfKVhMXTOf4HxauraegPVEz8VRbH15Pks5vEZ5cgaJpZM4PuOTA .

0reactions
RicoSutercommented, May 8, 2019

Looks like that would be a third option besides interface and class… please create a new issue in http://njsonschema.org

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found