Skip to content

Delivery API: Include Element names in the Delivery API output (closes #23242) - #23260

Merged
AndyButland merged 5 commits into
mainfrom
v18/improvement/element-name-in-delivery-api
Jul 2, 2026
Merged

Delivery API: Include Element names in the Delivery API output (closes #23242)#23260
AndyButland merged 5 commits into
mainfrom
v18/improvement/element-name-in-delivery-api

Conversation

@kjac

@kjac kjac commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #23242

Description

This adds Element names to the Delivery API output. See #23242 for details.

Breaking?

The Delivery API schema changes with this PR:

  1. The name property changes position for IApiContentResponseModel, IApiContentBaseModel and `IApiContentResponseBaseModel´ (depending on your schema generation configuration).
  2. The IApiElementBaseModel model gains a name property.

Neither of these changes should be breaking - but please take the time to consider it 😄

Testing this PR

Fetch content with an element picker through the Delivery API. The response should contain the element name.

@kjac kjac changed the title Include Element names in the Delivery API output Delivery API: Include Element names in the Delivery API output Jul 1, 2026
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Claude finished @kjac's task in 4m 0s —— View job


PR Review

Target: origin/main · Based on commit: f2c63013 · Skipped: 0 noise files out of 10 total

Moves the Name property from IApiContent down to IApiElement, making element names available in the Delivery API response for element-picker properties. Adds a non-breaking constructor overload for ApiElement and updates tests and OpenAPI contracts accordingly.

  • Modified public API: IApiElement (new Name property), ApiElement (new constructor, old obsoleted), IApiContent (Name removed — now inherited from IApiElement)
  • Affected implementations (outside this PR): Any external code directly implementing IApiElement (not via ApiElement) will fail to compile without a default on the new member.
  • Other changes: Delivery API responses for element pickers now include a name field; name property position shifted in OpenAPI schemas for content models (cosmetic, non-breaking for JSON consumers).

Important

  • src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs:18: string? Name { get; } is added to a public interface without a default implementation. Per CLAUDE.md §5.3, adding a member to a public interface requires a default implementation to avoid breaking external implementors. → Add => null; as a default with the standard TODO comment:
    string? Name { get; }
        => null; // TODO (V20): Remove the default implementation when the obsolete ApiElement constructor is removed.

Suggestions

  • src/Umbraco.Core/Models/DeliveryApi/ApiElement.cs:11: The obsolete constructor defaults name to string.Empty. Since IApiElement.Name is string?, defaulting to null is slightly more expressive ("no name was provided") vs. an empty string that would serialize as "" in the API response. Either is fine since this is an obsolete path only used by external consumers constructing the object directly — just worth considering.

Request Changes

One breaking-change mitigation is missing: IApiElement.Name needs a default implementation before merge.

@kjac kjac changed the title Delivery API: Include Element names in the Delivery API output Delivery API: Include Element names in the Delivery API output (closes #23242) Jul 1, 2026
Comment thread src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs Outdated

@AndyButland AndyButland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected @kjac - in testing I could see the name for a delivery API property output for an element picker missing before this PR is applied, but it's included afterward:

  "pickedElement": [
      {
          "contentType": "testElement",
          "id": "d0a70606-cb11-41aa-9385-ad4110645b6a",
          "name": "yyy",
          "properties": {
              "text": "zzz"
          }
      }

I've fixed up the two issues noted around default property syntax and the interface breaking change,

Comment thread src/Umbraco.Core/Models/DeliveryApi/IApiContent.cs
Comment thread src/Umbraco.Core/Models/DeliveryApi/IApiElement.cs Outdated
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delivery API Not exposing Element Name

2 participants