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.
This commit is contained in:
committed by
Sebastiaan Janssen
parent
4d80073547
commit
efe00910f3
@@ -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<string, object?> Properties { get; }
|
||||
|
||||
@@ -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<string, object?> Properties { get; }
|
||||
|
||||
Reference in New Issue
Block a user