Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Umbraco.Core/DeliveryApi/ApiElementBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public IApiElement Build(IPublishedElement element)

return new ApiElement(
element.Key,
element.Name,
element.ContentType.Alias,
properties);
}
Expand Down
6 changes: 1 addition & 5 deletions src/Umbraco.Core/Models/DeliveryApi/ApiContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ public class ApiContent : ApiElement, IApiContent
/// <param name="route">The route information for the content.</param>
/// <param name="properties">The property values of the content.</param>
public ApiContent(Guid id, string name, string contentType, DateTime createDate, DateTime updateDate, IApiContentRoute route, IDictionary<string, object?> properties)
: base(id, contentType, properties)
: base(id, name, contentType, properties)
{
Name = name;
CreateDate = createDate;
UpdateDate = updateDate;
Route = route;
}

/// <inheritdoc />
public string Name { get; }

/// <inheritdoc />
public DateTime CreateDate { get; }

Expand Down
13 changes: 12 additions & 1 deletion src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@ namespace Umbraco.Cms.Core.Models.DeliveryApi;
/// </summary>
public class ApiElement : IApiElement
{
[Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 20.")]
public ApiElement(Guid id, string contentType, IDictionary<string, object?> properties)
: this(id, string.Empty, contentType, properties)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ApiElement" /> class.
/// </summary>
/// <param name="id">The unique identifier of the element.</param>
/// <param name="name">The name of the element.</param>
/// <param name="contentType">The content type alias of the element.</param>
/// <param name="properties">The property values of the element.</param>
public ApiElement(Guid id, string contentType, IDictionary<string, object?> properties)
public ApiElement(Guid id, string name, string contentType, IDictionary<string, object?> properties)
{
Id = id;
Name = name;
ContentType = contentType;
Properties = properties;
}

/// <inheritdoc />
public Guid Id { get; }

/// <inheritdoc />
public string Name { get; }

/// <summary>
/// Gets the content type alias of the element.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ namespace Umbraco.Cms.Core.Models.DeliveryApi;
/// </summary>
public interface IApiContent : IApiElement
{
/// <summary>
/// Gets the name of the content.
/// </summary>
string? Name { get; }
Comment thread
AndyButland marked this conversation as resolved.
Resolved

/// <summary>
/// Gets the date and time when the content was created.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
/// </summary>
Guid Id { get; }

/// <summary>
/// Gets the name of the element.
/// </summary>
// TODO (V19): Remove the default implementations from this interface.
string? Name { get; } => null;

Check failure on line 19 in src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs

View workflow job for this annotation

GitHub Actions / Build and analyze

Block bodies and expression bodies cannot both be provided.
Comment thread
AndyButland marked this conversation as resolved.
Resolved

/// <summary>
/// Gets the content type alias of the element.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,12 +1173,6 @@
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"createDate": {
"type": "string",
"format": "date-time"
Expand All @@ -1194,6 +1188,12 @@
"type": "string",
"format": "uuid"
},
"name": {
"type": [
"null",
"string"
]
},
"properties": {
"type": [
"null",
Expand Down Expand Up @@ -1519,4 +1519,4 @@
"name": "Media"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1173,12 +1173,6 @@
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"createDate": {
"type": "string",
"format": "date-time"
Expand All @@ -1194,6 +1188,12 @@
"type": "string",
"format": "uuid"
},
"name": {
"type": [
"null",
"string"
]
},
"properties": {
"type": [
"null",
Expand Down Expand Up @@ -1519,4 +1519,4 @@
"name": "Media"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1284,12 +1284,6 @@
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"createDate": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -1342,6 +1336,12 @@
"type": "string",
"format": "uuid"
},
"name": {
"type": [
"null",
"string"
]
},
"properties": {
"type": [
"null",
Expand Down Expand Up @@ -1377,12 +1377,6 @@
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"createDate": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -1435,6 +1429,12 @@
"type": "string",
"format": "uuid"
},
"name": {
"type": [
"null",
"string"
]
},
"properties": {
"type": [
"null",
Expand Down Expand Up @@ -1516,6 +1516,12 @@
"type": "string",
"format": "uuid"
},
"name": {
"type": [
"null",
"string"
]
},
"properties": {
"type": [
"null",
Expand Down Expand Up @@ -2261,4 +2267,4 @@
"name": "Media"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1397,12 +1397,6 @@
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"createDate": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -1455,6 +1449,12 @@
"type": "string",
"format": "uuid"
},
"name": {
"type": [
"null",
"string"
]
},
"properties": {
"type": [
"null",
Expand Down Expand Up @@ -1510,12 +1510,6 @@
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"createDate": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -1568,6 +1562,12 @@
"type": "string",
"format": "uuid"
},
"name": {
"type": [
"null",
"string"
]
},
"properties": {
"type": [
"null",
Expand Down Expand Up @@ -1669,6 +1669,12 @@
"type": "string",
"format": "uuid"
},
"name": {
"type": [
"null",
"string"
]
},
"properties": {
"type": [
"null",
Expand Down Expand Up @@ -2745,4 +2751,4 @@
"name": "Media"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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]);
Expand Down
Loading