ServiceComposer.AspNetCore

Output formatters

Available starting with v1.9.0

Enabling output formatters support is a metter of:

public void ConfigureServices(IServiceCollection services)
{
    services.AddViewModelComposition(options =>
    {
        options.ResponseSerialization.UseOutputFormatters = true;
    });
    services.AddControllers();
}

snippet source | anchor

The required steps are:

The above configuration uses the new System.Text.Json serializer as the default json serializer to format json responses. The System.Text.Json serializer does not support serializing dynamic objects. It’s possible to plug-in the Newtonsoft Json.Net serializer as output formatter by adding a package reference to the Microsoft.AspNetCore.Mvc.NewtonsoftJson package, and using the following configuration:

public void ConfigureServices(IServiceCollection services)
{
    services.AddViewModelComposition(options =>
    {
        options.ResponseSerialization.UseOutputFormatters = true;
    });
    services.AddControllers()
        .AddNewtonsoftJson();
}

snippet source | anchor