Skip to content

Commit f071c0c

Browse files
fix(hydra): optimisation
1 parent 917a0df commit f071c0c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Hydra/Serializer/DocumentationNormalizer.php

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

7676
$shortName = $resourceMetadata->getShortName();
77+
7778
$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);
@@ -243,8 +244,7 @@ private function getHydraOperations(bool $collection, ?ResourceMetadataCollectio
243244
if (('POST' === $operation->getMethod() || $operation instanceof CollectionOperationInterface) !== $collection) {
244245
continue;
245246
}
246-
247-
$hydraOperations[] = $this->getHydraOperation($operation, $operation->getTypes()[0] ?? "#{$operation->getShortName()}", $hydraPrefix);
247+
$hydraOperations[] = $this->getHydraOperation($operation, $operation->getShortName(), $hydraPrefix);
248248
}
249249
}
250250

@@ -280,28 +280,28 @@ private function getHydraOperation(HttpOperation $operation, string $prefixedSho
280280
$hydraOperation += [
281281
'@type' => [$hydraPrefix.'Operation', 'schema:FindAction'],
282282
$hydraPrefix.'title' => "Retrieves a $shortName resource.",
283-
'returns' => null === $outputClass ? 'owl:Nothing' : substr($prefixedShortName, 1),
283+
'returns' => null === $outputClass ? 'owl:Nothing' : $prefixedShortName,
284284
];
285285
} elseif ('PATCH' === $method) {
286286
$hydraOperation += [
287287
'@type' => $hydraPrefix.'Operation',
288288
$hydraPrefix.'title' => "Updates the $shortName resource.",
289-
'returns' => null === $outputClass ? 'owl:Nothing' : substr($prefixedShortName, 1),
290-
'expects' => null === $inputClass ? 'owl:Nothing' : substr($prefixedShortName, 1),
289+
'returns' => null === $outputClass ? 'owl:Nothing' : $prefixedShortName,
290+
'expects' => null === $inputClass ? 'owl:Nothing' : $prefixedShortName,
291291
];
292292
} elseif ('POST' === $method) {
293293
$hydraOperation += [
294294
'@type' => [$hydraPrefix.'Operation', 'schema:CreateAction'],
295295
$hydraPrefix.'title' => "Creates a $shortName resource.",
296-
'returns' => null === $outputClass ? 'owl:Nothing' : substr($prefixedShortName, 1),
297-
'expects' => null === $inputClass ? 'owl:Nothing' : substr($prefixedShortName, 1),
296+
'returns' => null === $outputClass ? 'owl:Nothing' : $prefixedShortName,
297+
'expects' => null === $inputClass ? 'owl:Nothing' : $prefixedShortName,
298298
];
299299
} elseif ('PUT' === $method) {
300300
$hydraOperation += [
301301
'@type' => [$hydraPrefix.'Operation', 'schema:ReplaceAction'],
302302
$hydraPrefix.'title' => "Replaces the $shortName resource.",
303-
'returns' => null === $outputClass ? 'owl:Nothing' : substr($prefixedShortName, 1),
304-
'expects' => null === $inputClass ? 'owl:Nothing' : substr($prefixedShortName, 1),
303+
'returns' => null === $outputClass ? 'owl:Nothing' : $prefixedShortName,
304+
'expects' => null === $inputClass ? 'owl:Nothing' : $prefixedShortName,
305305
];
306306
} elseif ('DELETE' === $method) {
307307
$hydraOperation += [

0 commit comments

Comments
 (0)