diff --git a/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs b/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs index b7d10814fc..d5941a1ed1 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs @@ -1,3 +1,5 @@ +using System.Text.Json.Serialization; + namespace Umbraco.Cms.Core.Models.DeliveryApi; public class ApiElement : IApiElement @@ -11,6 +13,9 @@ public class ApiElement : IApiElement public Guid Id { get; } + // Ensure the ContentType property is serialized first + // This is needed so it can be used as a discriminator field by System.Text.Json + [JsonPropertyOrder(-100)] public string ContentType { get; } public IDictionary Properties { get; } diff --git a/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs b/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs index 7630225f64..e62525aa34 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs @@ -1,9 +1,14 @@ +using System.Text.Json.Serialization; + namespace Umbraco.Cms.Core.Models.DeliveryApi; public interface IApiElement { Guid Id { get; } + // Ensure the ContentType property is serialized first + // This is needed so it can be used as a discriminator field by System.Text.Json + [JsonPropertyOrder(-100)] string ContentType { get; } IDictionary Properties { get; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/BlockListPropertyValueConverter.cs b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/BlockListPropertyValueConverter.cs index 334b1f1aa3..52efe3755a 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/BlockListPropertyValueConverter.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/BlockListPropertyValueConverter.cs @@ -113,7 +113,7 @@ public class BlockListPropertyValueConverter : BlockPropertyValueConverterBase public Type GetDeliveryApiPropertyValueType(IPublishedPropertyType propertyType) - => typeof(IEnumerable); + => typeof(ApiBlockListModel); /// public object? ConvertIntermediateToDeliveryApiObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview, bool expanding)