Skip to content

Commit 1b268ac

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

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Hydra/Serializer/DocumentationNormalizer.php

Lines changed: 6 additions & 9 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,10 +270,6 @@ 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-
}
275-
276273
if ('GET' === $method && $operation instanceof CollectionOperationInterface) {
277274
$hydraOperation += [
278275
'@type' => [$hydraPrefix.'Operation', 'schema:FindAction'],
@@ -382,8 +379,8 @@ private function getRange(ApiProperty $propertyMetadata): array|string|null
382379
$operation = $resourceMetadata->getOperation();
383380

384381
if (!$operation instanceof HttpOperation || !$operation->getTypes()) {
385-
if (!\in_array("#{$operation->getShortName()}", $types, true)) {
386-
$types[] = "#{$operation->getShortName()}";
382+
if (!\in_array($operation->getShortName(), $types, true)) {
383+
$types[] = $operation->getShortName();
387384
}
388385
break;
389386
}
@@ -511,7 +508,7 @@ private function getProperty(ApiProperty $propertyMetadata, string $propertyName
511508
}
512509

513510
if (!isset($iri)) {
514-
$iri = "#$shortName/$propertyName";
511+
$iri = "$shortName/$propertyName";
515512
}
516513

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

0 commit comments

Comments
 (0)