Skip to content

docs(jsonld): drop misleading @type TODO, document intentional behavior#8369

Merged
soyuka merged 1 commit into
api-platform:mainfrom
soyuka:chore/jsonld-type-todo
Jun 30, 2026
Merged

docs(jsonld): drop misleading @type TODO, document intentional behavior#8369
soyuka merged 1 commit into
api-platform:mainfrom
soyuka:chore/jsonld-type-todo

Conversation

@soyuka

@soyuka soyuka commented Jun 30, 2026

Copy link
Copy Markdown
Member
Q A
Branch? main
Tickets
License MIT
Doc PR

The // TODO: 5.x break on this... block in JsonLd\Serializer\ItemNormalizer::resolveType() claimed that, for item_uri_template collections, the member @type should be derived from the object's class instead of the operation. The comment hedged itself ("this looks wrong ... ?").

After investigation the premise is wrong: members deliberately carry the item resource's @type so it matches their @id, which dereferences to the item_uri_template operation rather than to the collection's own resource. Two functional tests rely on exactly this:

  • ItemUriTemplateCollectionTestRecipeCollection (shortName CollectionRecipe) members expose @type: Recipe.
  • ItemUriTemplateHydraTest::testCollectionReferencingAnotherResourceCollectionReferencingItem members expose @type: ItemReferencedInCollection.

Both have object class ≠ item resource, and both assert the item operation's shortName. PR #7764 added this branch precisely to restore that behavior. Switching to the object's class would break RecipeCollection.

No behavioral change: this drops the misleading TODO and replaces the inner comment with one explaining the invariant.

The TODO claimed item_uri_template member @type should derive from the
object's class instead of the operation. That contradicts the deliberate,
tested behavior: members carry the item resource's @type so it matches
their @id (which dereferences to the item_uri_template operation, not the
collection's own resource). RecipeCollection -> Recipe and
CollectionReferencingItem -> ItemReferencedInCollection both rely on this,
and PR api-platform#7764 added the branch precisely to restore it. Replace the wrong
TODO with a comment explaining the invariant.
@soyuka soyuka merged commit 7dfba0c into api-platform:main Jun 30, 2026
91 of 97 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant