Files
Umbraco-CMS/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs
Vitor Rodrigues efe00910f3 DeliveryApi: Ensure the ContentType property is serialized first
This is needed so it can be used as a discriminator field by System.Text.Json
Changed both ApiElement and IApiElement to ensure not only ApiContentResponse,
but also ApiBlockItem, which uses the interface directly, are adjusted.
2023-08-29 12:34:36 +02:00

23 lines
622 B
C#

using System.Text.Json.Serialization;
namespace Umbraco.Cms.Core.Models.DeliveryApi;
public class ApiElement : IApiElement
{
public ApiElement(Guid id, string contentType, IDictionary<string, object?> properties)
{
Id = id;
ContentType = contentType;
Properties = properties;
}
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<string, object?> Properties { get; }
}