Skip to content

Commit 3689ae5

Browse files
authored
fix(hydra): owl:maxCardinality should be an int (#6235)
1 parent 0073a2a commit 3689ae5

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

features/hydra/docs.feature

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Feature: Documentation support
6969
And the value of the node "hydra:property.domain" of the property "name" of the Hydra class "Dummy" is "#Dummy"
7070
And the value of the node "hydra:property.range" of the property "name" of the Hydra class "Dummy" is "xmls:string"
7171
And the value of the node "hydra:property.range" of the property "relatedDummy" of the Hydra class "Dummy" is "https://schema.org/Product"
72+
And the value of the node "hydra:property.owl:maxCardinality" of the property "relatedDummy" of the Hydra class "Dummy" is "1"
7273
And the value of the node "hydra:property.range" of the property "relatedDummies" of the Hydra class "Dummy" is "https://schema.org/Product"
7374
And the value of the node "hydra:title" of the property "name" of the Hydra class "Dummy" is "name"
7475
And the value of the node "hydra:description" of the property "name" of the Hydra class "Dummy" is "The dummy name"
@@ -84,6 +85,6 @@ Feature: Documentation support
8485
And the value of the node "returns" of the operation "DELETE" of the Hydra class "Dummy" is "owl:Nothing"
8586
# Deprecations
8687
And the boolean value of the node "owl:deprecated" of the Hydra class "DeprecatedResource" is true
87-
And the boolean value of the node "owl:deprecated" of the property "deprecatedField" of the Hydra class "DeprecatedResource" is true
88+
And the boolean value of the node "hydra:property.owl:deprecated" of the property "deprecatedField" of the Hydra class "DeprecatedResource" is true
8889
And the boolean value of the node "owl:deprecated" of the property "The collection of DeprecatedResource resources" of the Hydra class "The API entrypoint" is true
8990
And the boolean value of the node "owl:deprecated" of the operation "GET" of the Hydra class "DeprecatedResource" is true

src/Hydra/Serializer/DocumentationNormalizer.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,18 @@ private function getProperty(ApiProperty $propertyMetadata, string $propertyName
505505
'domain' => $prefixedShortName,
506506
];
507507

508+
if ($propertyMetadata->getDeprecationReason()) {
509+
$propertyData['owl:deprecated'] = true;
510+
}
511+
512+
if ($this->isSingleRelation($propertyMetadata)) {
513+
$propertyData['owl:maxCardinality'] = 1;
514+
}
515+
516+
if (null !== $range = $this->getRange($propertyMetadata)) {
517+
$propertyData['range'] = $range;
518+
}
519+
508520
$property = [
509521
'@type' => 'hydra:SupportedProperty',
510522
'hydra:property' => $propertyData,
@@ -514,22 +526,10 @@ private function getProperty(ApiProperty $propertyMetadata, string $propertyName
514526
'hydra:writeable' => $propertyMetadata->isWritable() || $propertyMetadata->isInitializable(),
515527
];
516528

517-
if (null !== $range = $this->getRange($propertyMetadata)) {
518-
$property['hydra:property']['range'] = $range;
519-
}
520-
521529
if (null !== $description = $propertyMetadata->getDescription()) {
522530
$property['hydra:description'] = $description;
523531
}
524532

525-
if ($propertyMetadata->getDeprecationReason()) {
526-
$property['owl:deprecated'] = true;
527-
}
528-
529-
if ($this->isSingleRelation($propertyMetadata)) {
530-
$property['owl:maxCardinality'] = true;
531-
}
532-
533533
return $property;
534534
}
535535

0 commit comments

Comments
 (0)