From 9ac53e358796af7a9fa35c62b58deef9a91d94d0 Mon Sep 17 00:00:00 2001 From: Abderrahim GHAZALI Date: Fri, 1 May 2026 19:30:35 +0200 Subject: [PATCH] feat(hydra): use hydra:memberAssertion instead of owl:equivalentClass Per the Hydra Core spec (hydra-cg.com/spec/latest/core/), entrypoint collection properties now declare member semantics via a `hydra:memberAssertion` block (subject/property/object) rather than the legacy `owl:equivalentClass`/`owl:allValuesFrom` restriction. Aligns the API documentation with the modern term and removes the awkward OWL block. Refs api-platform/core#2827, HydraCG/Specifications#195 --- .../Serializer/DocumentationNormalizer.php | 12 +++----- .../DocumentationNormalizerTest.php | 28 +++++++------------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/Hydra/Serializer/DocumentationNormalizer.php b/src/Hydra/Serializer/DocumentationNormalizer.php index 428c6da7a9..14fbee9c03 100644 --- a/src/Hydra/Serializer/DocumentationNormalizer.php +++ b/src/Hydra/Serializer/DocumentationNormalizer.php @@ -108,14 +108,10 @@ private function populateEntrypointProperties(ApiResource $resourceMetadata, str '@type' => $hydraPrefix.'Link', 'domain' => '#Entrypoint', 'owl:maxCardinality' => 1, - 'range' => [ - ['@id' => 'hydra:Collection'], - [ - 'owl:equivalentClass' => [ - 'owl:onProperty' => ['@id' => 'hydra:member'], - 'owl:allValuesFrom' => ['@id' => $prefixedShortName], - ], - ], + 'range' => 'hydra:Collection', + $hydraPrefix.'memberAssertion' => [ + $hydraPrefix.'property' => ['@id' => 'rdf:type'], + $hydraPrefix.'object' => ['@id' => $prefixedShortName], ], $hydraPrefix.'supportedOperation' => $hydraCollectionOperations, ], diff --git a/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php b/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php index f9ca871d9e..1780a949f8 100644 --- a/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php +++ b/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php @@ -333,16 +333,12 @@ private function doTestNormalize($resourceMetadataFactory = null): void '@id' => '#Entrypoint/dummy', '@type' => 'hydra:Link', 'domain' => '#Entrypoint', - 'range' => [ - ['@id' => 'hydra:Collection'], - [ - 'owl:equivalentClass' => [ - 'owl:onProperty' => ['@id' => 'hydra:member'], - 'owl:allValuesFrom' => ['@id' => '#dummy'], - ], - ], - ], 'owl:maxCardinality' => 1, + 'range' => 'hydra:Collection', + 'hydra:memberAssertion' => [ + 'hydra:property' => ['@id' => 'rdf:type'], + 'hydra:object' => ['@id' => '#dummy'], + ], 'hydra:supportedOperation' => [ [ '@type' => ['hydra:Operation', 'schema:FindAction'], @@ -898,16 +894,12 @@ public function testNormalizeWithoutPrefix(): void '@id' => '#Entrypoint/dummy', '@type' => 'Link', 'domain' => '#Entrypoint', - 'range' => [ - ['@id' => 'hydra:Collection'], - [ - 'owl:equivalentClass' => [ - 'owl:onProperty' => ['@id' => 'hydra:member'], - 'owl:allValuesFrom' => ['@id' => '#dummy'], - ], - ], - ], 'owl:maxCardinality' => 1, + 'range' => 'hydra:Collection', + 'memberAssertion' => [ + 'property' => ['@id' => 'rdf:type'], + 'object' => ['@id' => '#dummy'], + ], 'supportedOperation' => [ [ '@type' => ['Operation', 'schema:FindAction'],