Utf8Json icon indicating copy to clipboard operation
Utf8Json copied to clipboard

Using w/ Swashbuckle's ISerializerDataContractResolver

Open Sliverb opened this issue 3 years ago • 1 comments

Hi all, I swapped out System.Text.Json for this project with the code below

options.OutputFormatters.RemoveType<SystemTextJsonOutputFormatter>();
options.OutputFormatters.Add(new JsonOutputFormatter(ApiJsonSerializer.DefaultResolver));

options.InputFormatters.RemoveType<SystemTextJsonInputFormatter>();
options.InputFormatters.Add(new JsonInputFormatter(ApiJsonSerializer.DefaultResolver));

I just brought in swashbuckle and it seems to be unable to resolve request models and response types. My guess is due to switching out the input formatters. When i switch back to the default formatters, everything works as designed.

From looking at the swashbuckle code that allows folks to switch back to Newtonsoft, it looks like we need to create a class that implements ISerializerDataContractResolver and return it as swashbuckle's resolver. I am not sure where to start on this and am hoping someone in the community has either done this before or knows how to.

Any help will be appreciated.

Thanks

Sliverb avatar Sep 15 '20 22:09 Sliverb