RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.61k stars 1.22k forks source link

Date fields as string if typeStyle is Interface, but interface field as Date #4898

Open gennadiipetrov opened 1 month ago

gennadiipetrov commented 1 month ago

Hi. I use typeStyle as Interface in nswag file. And it generate DTOs fields as Date for dates. but in code it is string. I found this https://github.com/RicoSuter/NSwag/issues/980 topic.

Are there some changes now (I mean 2024 year)? Can you give me some workaround for this? I want to use interfaces.

PooSham commented 1 week ago

but in code it is string

By that, do you mean that the runtime type is string? I also thought this used to work, but I'm doubting my memory... I'm trying to find in the generated api client if there are any changes that have affected this, but I can't find it. Maybe something changed in NJsonSchema?

I guess the solution is to implement jsonReviver on every class, by extending the classes and using the extended class as your services. But that's quite annoying.