Skip to content

Instantly share code, notes, and snippets.

@Hangsolow
Created April 14, 2020 07:51
Show Gist options
  • Save Hangsolow/186592c639f2c72f640b61cc3dea4fb9 to your computer and use it in GitHub Desktop.
Save Hangsolow/186592c639f2c72f640b61cc3dea4fb9 to your computer and use it in GitHub Desktop.
Content Delivery API config
[ModuleDependency(typeof(ContentApiCmsInitialization))]
public class ContentDeliveryApiInitialization : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Services.Configure<ContentApiConfiguration>(config =>
{
config.Default()
.SetMinimumRoles(string.Empty)
.SetFlattenPropertyModel(true)
.SetIncludeNullValues(true)
.SetIncludeMasterLanguage(false)
.SetValidateTemplateForContentUrl(true)
.SetExtendedContentTypeModel(true);
});
}
public void Initialize(InitializationEngine context)
{
var jsonSerializer = context.Locate.Advanced.GetInstance<JsonSerializer>();
jsonSerializer.Settings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
}
public void Uninitialize(InitializationEngine context)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment