Open Numpsy opened 3 years ago
On a related note, at least some versions of the NSwag schema generator will generate a schema that specifies a type of 'string' for such properties when the server is set up to use System.Text.Json as the Json serializer, even though its default behavior is to serialize System.TimeSpan to an object - which causes 'fun' with a client that expects to deserialize a string - but that's a seperate issue (Hawaiis schema patching options are useful there :-) )
Hi @Numpsy I think it is a good idea to add support for date-span
(swashbuckle) and time-span
(nswag) and convert them into TimeSpan
directly. One problem I see here is the Fable serializer doesn't know how to handle the different formats and will require testing.
Speaking of testing, the codebase has become a bit large and I think that before I implement more features, I need to properly do integration testing: setting up a bunch of projects that generate clients from the latest Hawaii source and runs them against backends exposed from nswag/swashbuckle/odata, then assert their responses.
Long story short, it will take a while before I can start implmenting more features 😓
Hi,
A question\request about possible support for TimeSpan types in generated F# clients.
Say that you have an ASP.Net Core API that returns an object with properties of type System.TimeSpan (e.g. https://github.com/Numpsy/OpenApiExample/blob/timespans/Common/SpecTestController.cs), using NewtonSoft.Json as a serializer, and you use NSwag to generate a schema for the server.
That will generate an OpenApi schema such as this
So the TimeSpan is represented as a string with the custom format
time-span
. If you point NSwags own C# client generator at that, it will recognize the custom format and generateAnd I was wondering if you'd have any thoughts about doing the same in the Hawaii F# generator?
If you do the same thing but generate the server schema with Swashbuckle then you get this schema
Which is similar except the custom format is
date-span
rather thantime-span
, because who needs consistency :-( (NSwags client generator seems to generate plain string properties for this one)