From 3c8659fdcc102cdcebb439371b57c30e71a78427 Mon Sep 17 00:00:00 2001 From: soyuka Date: Thu, 24 Oct 2024 15:07:26 +0200 Subject: [PATCH] fix(hydra): rdfs:label should not duplicate title --- src/Hydra/Serializer/DocumentationNormalizer.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Hydra/Serializer/DocumentationNormalizer.php b/src/Hydra/Serializer/DocumentationNormalizer.php index 0cae690f683..17aeca34b20 100644 --- a/src/Hydra/Serializer/DocumentationNormalizer.php +++ b/src/Hydra/Serializer/DocumentationNormalizer.php @@ -99,7 +99,7 @@ private function populateEntrypointProperties(ApiResource $resourceMetadata, str '@id' => \sprintf('#Entrypoint/%s', lcfirst($shortName)), '@type' => $hydraPrefix.'Link', 'domain' => '#Entrypoint', - 'rdfs:label' => "The collection of $shortName resources", + 'rdfs:label' => "get{$shortName}Collection", 'rdfs:range' => [ ['@id' => $hydraPrefix.'Collection'], [ @@ -313,8 +313,9 @@ private function getHydraOperation(HttpOperation $operation, string $prefixedSho $hydraOperation[$hydraPrefix.'method'] ?? $hydraOperation[$hydraPrefix.'method'] = $method; - if (!isset($hydraOperation['rdfs:label']) && isset($hydraOperation[$hydraPrefix.'title'])) { - $hydraOperation['rdfs:label'] = $hydraOperation[$hydraPrefix.'title']; + if (!isset($hydraOperation['rdfs:label'])) { + // we know that this name is unique + $hydraOperation['rdfs:label'] = $operation->getName(); } ksort($hydraOperation); @@ -429,7 +430,8 @@ private function getClasses(array $entrypointProperties, array $classes, string $hydraPrefix.'supportedOperation' => [ '@type' => $hydraPrefix.'Operation', $hydraPrefix.'method' => 'GET', - 'rdfs:label' => 'The API entrypoint.', + 'title' => 'The API entrypoint.', + 'rdfs:label' => 'getEntrypoint', 'returns' => 'EntryPoint', ], ];