You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I think it should be one more extension method that allows passing custom JsonSerializerSettings as well. In my case, I just copy/paste the class and refactored it, but its better for not to have hacked code in the projects
namespace Microsoft.Extensions.DependencyInjection
{
public static class NewtonsoftServiceCollectionExtensions
{
public static IServiceCollection AddSwaggerGenNewtonsoftSupport(this IServiceCollection services)
{
return services.Replace(
ServiceDescriptor.Transient<ISerializerDataContractResolver>((s) =>
{
var serializerSettings = s.GetRequiredService<IOptions<MvcNewtonsoftJsonOptions>>().Value?.SerializerSettings
?? **new JsonSerializerSettings()**;
return new NewtonsoftDataContractResolver(serializerSettings);
}));
}
}
}
As noted in #2799, this adds too much complexity. Providing custom implementations in the service container is the way to provide exacting behaviour for your needs.
Also, as we support two serializers, this doubles the amount of work needed if we did do this.
Hi,
I think it should be one more extension method that allows passing custom JsonSerializerSettings as well. In my case, I just copy/paste the class and refactored it, but its better for not to have hacked code in the projects
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/fcbec2c701a7e0533c3ec6f1bbc5232780bade0f/src/Swashbuckle.AspNetCore.Newtonsoft/DependencyInjection/NewtonsoftServiceCollectionExtensions.cs
The text was updated successfully, but these errors were encountered: