Skip to content

Commit 57f146a

Browse files
fix(hydra): remove some #
1 parent d9421d9 commit 57f146a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/Hydra/Serializer/DocumentationNormalizer.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public function normalize(mixed $object, ?string $format = null, array $context
7474
}
7575

7676
$shortName = $resourceMetadata->getShortName();
77-
$prefixedShortName = $resourceMetadata->getTypes()[0] ?? "#$shortName";
77+
78+
$prefixedShortName = $resourceMetadata->getTypes()[0] ?? $shortName;
7879
$this->populateEntrypointProperties($resourceMetadata, $shortName, $prefixedShortName, $entrypointProperties, $hydraPrefix, $resourceMetadataCollection);
7980
$classes[] = $this->getClass($resourceClass, $resourceMetadata, $shortName, $prefixedShortName, $context, $hydraPrefix, $resourceMetadataCollection);
8081
}
@@ -243,7 +244,7 @@ private function getHydraOperations(bool $collection, ?ResourceMetadataCollectio
243244
if (('POST' === $operation->getMethod() || $operation instanceof CollectionOperationInterface) !== $collection) {
244245
continue;
245246
}
246-
$hydraOperations[] = $this->getHydraOperation($operation, $operation->getTypes()[0] ?? $operation->getShortName(), $hydraPrefix);
247+
$hydraOperations[] = $this->getHydraOperation($operation, $operation->getShortName(), $hydraPrefix);
247248
}
248249
}
249250

@@ -269,9 +270,7 @@ private function getHydraOperation(HttpOperation $operation, string $prefixedSho
269270
$inputClass = \array_key_exists('class', $inputMetadata) ? $inputMetadata['class'] : false;
270271
$outputClass = \array_key_exists('class', $outputMetadata) ? $outputMetadata['class'] : false;
271272

272-
if (str_starts_with($prefixedShortName, '#')) {
273-
$prefixedShortName = substr($prefixedShortName, 1);
274-
}
273+
275274

276275
if ('GET' === $method && $operation instanceof CollectionOperationInterface) {
277276
$hydraOperation += [
@@ -382,8 +381,8 @@ private function getRange(ApiProperty $propertyMetadata): array|string|null
382381
$operation = $resourceMetadata->getOperation();
383382

384383
if (!$operation instanceof HttpOperation || !$operation->getTypes()) {
385-
if (!\in_array("#{$operation->getShortName()}", $types, true)) {
386-
$types[] = "#{$operation->getShortName()}";
384+
if (!\in_array($operation->getShortName(), $types, true)) {
385+
$types[] = $operation->getShortName();
387386
}
388387
break;
389388
}
@@ -511,7 +510,7 @@ private function getProperty(ApiProperty $propertyMetadata, string $propertyName
511510
}
512511

513512
if (!isset($iri)) {
514-
$iri = "#$shortName/$propertyName";
513+
$iri = "$shortName/$propertyName";
515514
}
516515

517516
$propertyData = ($propertyMetadata->getJsonldContext()[$hydraPrefix.'property'] ?? []) + [

0 commit comments

Comments
 (0)