Closed rsr-maersk closed 1 year ago
it seems like nswag only has support for automatically picking up the string-enum-converter from STJ. have a look here. all other custom converters from the STJ settings seems to be ignored.
as a solution, i've added the ability to add newtonsoft converters to the swagger document like so:
.SwaggerDocument(o =>
{
o.NewtonsoftSettings = s =>
{
s.Converters.Add(new ZonedDateTimeConverter());
};
});
the above is available in v5.15.0.19-beta
.
give it a shot and let me know if you encounter any issues.
thanks for bringing this to our attention.
@dj-nitehawk awesome. thanks!!!
@dj-nitehawk no cigar with the
.SwaggerDocument(o =>
{
o.NewtonsoftSettings = s =>
{
s.Converters.Add(new ZonedDateTimeConverter());
};
});
and package v5.15.0.19-beta didn't seam to do the trick. The custom converter wasn't being picked up
can you try the following project?
the custom converter does get called:
update the project and send back if you can reproduce the problem.
HI @dj-nitehawk Any update is the NSwag accepts the System.Json.Text SerializerSettings yet?
@rsr-maersk sadly still the same. uses newtonsoft mostly. so you're gonna need to make newtonsoft versions of any custom converters.
@rsr-maersk thought you might find this info interesting: https://discord.com/channels/933662816458645504/1255257287291834560/1255915229431332934
apparently, nswag doesn't have the ability to execute json converters when generating the swagger doc. custom converters added to the swagger doc would only get picked up by the FE swagger processor when generating examples and default values. if those code paths are not hit, custom converters are not used by nswag itself.
solution is to register something nswag calls a "type mapper". details in the discord thread.
@dj-nitehawk trying to open mentioned discord thread fails, so can't see suggested solution, but still, wondering if this should come as fast endpoints feature, so that people would not need to mangle through several places to set it up cleanly.
@dziedrius i believe you need to join the discord server first before being able to see posts there. use this invite link first and then click on the above link (which is still valid).
anyhow, this behavior is documented here.
wondering if this should come as fast endpoints feature
there's a limit to what FE can offer as conveniences. unfortunately this is one of the cases we haven't figured out a nice solution which requires the user to take care of it with the suggested solution. if someone has any ideas, PRs are always welcome.
Hi. Awesome package thanks!
We have added converts to swagger and fast endpoint registration. But the "Summary" does not seam to use it for the example.
registration
Looks like it is using ToString on the object and not the converters