From 90c5d2defabc35b0ae4ce49e96e01616944c7ba1 Mon Sep 17 00:00:00 2001 From: kjac Date: Wed, 1 Jul 2026 17:03:10 +0200 Subject: [PATCH 1/5] Include Element names in the Delivery API output --- .../DeliveryApi/ApiElementBuilder.cs | 1 + .../Models/DeliveryApi/ApiContent.cs | 6 +--- .../Models/DeliveryApi/ApiElement.cs | 13 +++++++- .../Models/DeliveryApi/IApiContent.cs | 5 --- .../Models/DeliveryApi/IApiElement.cs | 5 +++ .../OpenApi/ExpectedContracts/default.json | 14 ++++---- .../generic-schemas-with-sample-types.json | 14 ++++---- .../typed-schemas-empty-project.json | 32 +++++++++++-------- .../typed-schemas-with-sample-types.json | 32 +++++++++++-------- .../ElementPickerValueConverterTests.cs | 2 ++ 10 files changed, 73 insertions(+), 51 deletions(-) diff --git a/src/Umbraco.Core/DeliveryApi/ApiElementBuilder.cs b/src/Umbraco.Core/DeliveryApi/ApiElementBuilder.cs index 3d7a8a401393..83d2c8e4c9fa 100644 --- a/src/Umbraco.Core/DeliveryApi/ApiElementBuilder.cs +++ b/src/Umbraco.Core/DeliveryApi/ApiElementBuilder.cs @@ -29,6 +29,7 @@ public IApiElement Build(IPublishedElement element) return new ApiElement( element.Key, + element.Name, element.ContentType.Alias, properties); } diff --git a/src/Umbraco.Core/Models/DeliveryApi/ApiContent.cs b/src/Umbraco.Core/Models/DeliveryApi/ApiContent.cs index c2566905b034..e8ba0fcb5773 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/ApiContent.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/ApiContent.cs @@ -16,17 +16,13 @@ public class ApiContent : ApiElement, IApiContent /// The route information for the content. /// The property values of the content. public ApiContent(Guid id, string name, string contentType, DateTime createDate, DateTime updateDate, IApiContentRoute route, IDictionary properties) - : base(id, contentType, properties) + : base(id, name, contentType, properties) { - Name = name; CreateDate = createDate; UpdateDate = updateDate; Route = route; } - /// - public string Name { get; } - /// public DateTime CreateDate { get; } diff --git a/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs b/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs index d461878ac698..4410a84233b7 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs @@ -7,15 +7,23 @@ namespace Umbraco.Cms.Core.Models.DeliveryApi; /// public class ApiElement : IApiElement { + [Obsolete("TODO: SOMETHING V20")] + public ApiElement(Guid id, string contentType, IDictionary properties) + : this(id, string.Empty, contentType, properties) + { + } + /// /// Initializes a new instance of the class. /// /// The unique identifier of the element. + /// The name of the element. /// The content type alias of the element. /// The property values of the element. - public ApiElement(Guid id, string contentType, IDictionary properties) + public ApiElement(Guid id, string name, string contentType, IDictionary properties) { Id = id; + Name = name; ContentType = contentType; Properties = properties; } @@ -23,6 +31,9 @@ public ApiElement(Guid id, string contentType, IDictionary prop /// public Guid Id { get; } + /// + public string Name { get; } + /// /// Gets the content type alias of the element. /// diff --git a/src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs b/src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs index 7c3139972afa..54dd727a6bdc 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs @@ -5,11 +5,6 @@ namespace Umbraco.Cms.Core.Models.DeliveryApi; /// public interface IApiContent : IApiElement { - /// - /// Gets the name of the content. - /// - string? Name { get; } - /// /// Gets the date and time when the content was created. /// diff --git a/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs b/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs index 3a81fa17d04d..8b305cca66f1 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs @@ -12,6 +12,11 @@ public interface IApiElement /// Guid Id { get; } + /// + /// Gets the name of the element. + /// + string? Name { get; } + /// /// Gets the content type alias of the element. /// diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/default.json b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/default.json index 07c54adef18c..b1f18104f509 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/default.json +++ b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/default.json @@ -1173,12 +1173,6 @@ "string" ] }, - "name": { - "type": [ - "null", - "string" - ] - }, "createDate": { "type": "string", "format": "date-time" @@ -1194,6 +1188,12 @@ "type": "string", "format": "uuid" }, + "name": { + "type": [ + "null", + "string" + ] + }, "properties": { "type": [ "null", @@ -1519,4 +1519,4 @@ "name": "Media" } ] -} \ No newline at end of file +} diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/generic-schemas-with-sample-types.json b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/generic-schemas-with-sample-types.json index 07c54adef18c..b1f18104f509 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/generic-schemas-with-sample-types.json +++ b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/generic-schemas-with-sample-types.json @@ -1173,12 +1173,6 @@ "string" ] }, - "name": { - "type": [ - "null", - "string" - ] - }, "createDate": { "type": "string", "format": "date-time" @@ -1194,6 +1188,12 @@ "type": "string", "format": "uuid" }, + "name": { + "type": [ + "null", + "string" + ] + }, "properties": { "type": [ "null", @@ -1519,4 +1519,4 @@ "name": "Media" } ] -} \ No newline at end of file +} diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-empty-project.json b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-empty-project.json index b1d4c2373c88..11c0cf28bef7 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-empty-project.json +++ b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-empty-project.json @@ -1284,12 +1284,6 @@ "string" ] }, - "name": { - "type": [ - "null", - "string" - ] - }, "createDate": { "type": "string", "format": "date-time" @@ -1342,6 +1336,12 @@ "type": "string", "format": "uuid" }, + "name": { + "type": [ + "null", + "string" + ] + }, "properties": { "type": [ "null", @@ -1377,12 +1377,6 @@ "string" ] }, - "name": { - "type": [ - "null", - "string" - ] - }, "createDate": { "type": "string", "format": "date-time" @@ -1435,6 +1429,12 @@ "type": "string", "format": "uuid" }, + "name": { + "type": [ + "null", + "string" + ] + }, "properties": { "type": [ "null", @@ -1516,6 +1516,12 @@ "type": "string", "format": "uuid" }, + "name": { + "type": [ + "null", + "string" + ] + }, "properties": { "type": [ "null", @@ -2261,4 +2267,4 @@ "name": "Media" } ] -} \ No newline at end of file +} diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-with-sample-types.json b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-with-sample-types.json index 9762e77c3b25..e1e0664c2810 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-with-sample-types.json +++ b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-with-sample-types.json @@ -1397,12 +1397,6 @@ "string" ] }, - "name": { - "type": [ - "null", - "string" - ] - }, "createDate": { "type": "string", "format": "date-time" @@ -1455,6 +1449,12 @@ "type": "string", "format": "uuid" }, + "name": { + "type": [ + "null", + "string" + ] + }, "properties": { "type": [ "null", @@ -1510,12 +1510,6 @@ "string" ] }, - "name": { - "type": [ - "null", - "string" - ] - }, "createDate": { "type": "string", "format": "date-time" @@ -1568,6 +1562,12 @@ "type": "string", "format": "uuid" }, + "name": { + "type": [ + "null", + "string" + ] + }, "properties": { "type": [ "null", @@ -1669,6 +1669,12 @@ "type": "string", "format": "uuid" }, + "name": { + "type": [ + "null", + "string" + ] + }, "properties": { "type": [ "null", @@ -2745,4 +2751,4 @@ "name": "Media" } ] -} \ No newline at end of file +} diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/DeliveryApi/ElementPickerValueConverterTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/DeliveryApi/ElementPickerValueConverterTests.cs index 9ff896309577..7118fde5494d 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/DeliveryApi/ElementPickerValueConverterTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/DeliveryApi/ElementPickerValueConverterTests.cs @@ -40,6 +40,7 @@ public void ElementPickerValueConverter_BuildsDeliveryApiOutput() Assert.AreEqual(1, result!.Count()); var element = result.First(); Assert.AreEqual(PublishedElement.Key, element.Id); + Assert.AreEqual(PublishedElement.Name, element.Name); Assert.AreEqual("TheElementType", element.ContentType); Assert.IsEmpty(element.Properties); } @@ -86,6 +87,7 @@ public void ElementPickerValueConverter_RendersContentProperties() Assert.AreEqual(1, result!.Count()); var element = result.First(); Assert.AreEqual(key, element.Id); + Assert.AreEqual("The element", element.Name); Assert.AreEqual("theElementType", element.ContentType); Assert.AreEqual(2, element.Properties.Count); Assert.AreEqual("Delivery API value", element.Properties[DeliveryApiPropertyType.Alias]); From f2c63013b0a4df42f85bf51396938568260f9bdb Mon Sep 17 00:00:00 2001 From: kjac Date: Wed, 1 Jul 2026 17:05:47 +0200 Subject: [PATCH 2/5] Fix the obsoletion message --- src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs b/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs index 4410a84233b7..991160d3de3c 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs @@ -7,7 +7,7 @@ namespace Umbraco.Cms.Core.Models.DeliveryApi; /// public class ApiElement : IApiElement { - [Obsolete("TODO: SOMETHING V20")] + [Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 20.")] public ApiElement(Guid id, string contentType, IDictionary properties) : this(id, string.Empty, contentType, properties) { From 3eb7d0abfcd3a39843da054120eb3584cd671feb Mon Sep 17 00:00:00 2001 From: kjac Date: Wed, 1 Jul 2026 18:59:25 +0200 Subject: [PATCH 3/5] Address PR review --- src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs b/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs index 8b305cca66f1..1cc04e9b4a45 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs @@ -15,7 +15,8 @@ public interface IApiElement /// /// Gets the name of the element. /// - string? Name { get; } + // TODO (V19): Remove the default implementations from this interface. + string? Name { get; } => null; /// /// Gets the content type alias of the element. From 69f6c03b78d8145413f18740f9aaf971df7b3009 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Thu, 2 Jul 2026 08:23:37 +0200 Subject: [PATCH 4/5] Fixed default property syntax and resolved breaking change. --- src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs | 7 +++++++ src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs b/src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs index 54dd727a6bdc..8bb557bedf48 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs @@ -5,6 +5,13 @@ namespace Umbraco.Cms.Core.Models.DeliveryApi; /// public interface IApiContent : IApiElement { + /// + /// Gets the name of the content. + /// + // TODO (V19): Remove this declaration; it is retained only to preserve the IApiContent.Name binary slot for + // consumers compiled against v18.0. Name now lives on the IApiElement base interface. + new string? Name { get; } + /// /// Gets the date and time when the content was created. /// diff --git a/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs b/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs index 1cc04e9b4a45..9be47cf03dac 100644 --- a/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs +++ b/src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs @@ -16,7 +16,7 @@ public interface IApiElement /// Gets the name of the element. /// // TODO (V19): Remove the default implementations from this interface. - string? Name { get; } => null; + string? Name => null; /// /// Gets the content type alias of the element. From 6f14b8a1887ccc261b03ae325414b76a69c150bc Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Thu, 2 Jul 2026 10:36:38 +0200 Subject: [PATCH 5/5] Fixed failing contract tests. --- .../OpenApi/ExpectedContracts/default.json | 14 +++++----- .../generic-schemas-with-sample-types.json | 14 +++++----- .../typed-schemas-empty-project.json | 26 +++++++++---------- .../typed-schemas-with-sample-types.json | 26 +++++++++---------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/default.json b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/default.json index b1f18104f509..07c54adef18c 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/default.json +++ b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/default.json @@ -1173,6 +1173,12 @@ "string" ] }, + "name": { + "type": [ + "null", + "string" + ] + }, "createDate": { "type": "string", "format": "date-time" @@ -1188,12 +1194,6 @@ "type": "string", "format": "uuid" }, - "name": { - "type": [ - "null", - "string" - ] - }, "properties": { "type": [ "null", @@ -1519,4 +1519,4 @@ "name": "Media" } ] -} +} \ No newline at end of file diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/generic-schemas-with-sample-types.json b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/generic-schemas-with-sample-types.json index b1f18104f509..07c54adef18c 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/generic-schemas-with-sample-types.json +++ b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/generic-schemas-with-sample-types.json @@ -1173,6 +1173,12 @@ "string" ] }, + "name": { + "type": [ + "null", + "string" + ] + }, "createDate": { "type": "string", "format": "date-time" @@ -1188,12 +1194,6 @@ "type": "string", "format": "uuid" }, - "name": { - "type": [ - "null", - "string" - ] - }, "properties": { "type": [ "null", @@ -1519,4 +1519,4 @@ "name": "Media" } ] -} +} \ No newline at end of file diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-empty-project.json b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-empty-project.json index 11c0cf28bef7..5e64699489c8 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-empty-project.json +++ b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-empty-project.json @@ -1284,6 +1284,12 @@ "string" ] }, + "name": { + "type": [ + "null", + "string" + ] + }, "createDate": { "type": "string", "format": "date-time" @@ -1336,12 +1342,6 @@ "type": "string", "format": "uuid" }, - "name": { - "type": [ - "null", - "string" - ] - }, "properties": { "type": [ "null", @@ -1377,6 +1377,12 @@ "string" ] }, + "name": { + "type": [ + "null", + "string" + ] + }, "createDate": { "type": "string", "format": "date-time" @@ -1429,12 +1435,6 @@ "type": "string", "format": "uuid" }, - "name": { - "type": [ - "null", - "string" - ] - }, "properties": { "type": [ "null", @@ -2267,4 +2267,4 @@ "name": "Media" } ] -} +} \ No newline at end of file diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-with-sample-types.json b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-with-sample-types.json index e1e0664c2810..8e16772a1d0b 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-with-sample-types.json +++ b/tests/Umbraco.Tests.Integration/Umbraco.Api.Delivery/OpenApi/ExpectedContracts/typed-schemas-with-sample-types.json @@ -1397,6 +1397,12 @@ "string" ] }, + "name": { + "type": [ + "null", + "string" + ] + }, "createDate": { "type": "string", "format": "date-time" @@ -1449,12 +1455,6 @@ "type": "string", "format": "uuid" }, - "name": { - "type": [ - "null", - "string" - ] - }, "properties": { "type": [ "null", @@ -1510,6 +1510,12 @@ "string" ] }, + "name": { + "type": [ + "null", + "string" + ] + }, "createDate": { "type": "string", "format": "date-time" @@ -1562,12 +1568,6 @@ "type": "string", "format": "uuid" }, - "name": { - "type": [ - "null", - "string" - ] - }, "properties": { "type": [ "null", @@ -2751,4 +2751,4 @@ "name": "Media" } ] -} +} \ No newline at end of file