Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Using w/ Swashbuckle's ISerializerDataContractResolver #234

Open
Sliverb opened this issue Sep 15, 2020 · 1 comment
Open

Using w/ Swashbuckle's ISerializerDataContractResolver #234

Sliverb opened this issue Sep 15, 2020 · 1 comment

Comments

@Sliverb
Copy link

Sliverb commented Sep 15, 2020

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

@jacobboland
Copy link

@Sliverb I'm not sure if you got this working, but the closest answer I have seen to this is here. domaindrivendev/Swashbuckle.AspNetCore#2027. It would be nice if this could be a part of the Utf8Json formatters.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants