diff --git a/features/hydra/docs.feature b/features/hydra/docs.feature index de6da5aae8d..37109c898ca 100644 --- a/features/hydra/docs.feature +++ b/features/hydra/docs.feature @@ -15,11 +15,6 @@ Feature: Documentation support # Context And the Hydra context matches the online resource "http://www.w3.org/ns/hydra/context.jsonld" And the JSON node "@context[1].@vocab" should be equal to "http://example.com/docs.jsonld#" - And the JSON node "@context[1].hydra" should be equal to "http://www.w3.org/ns/hydra/core#" - And the JSON node "@context[1].rdf" should be equal to "http://www.w3.org/1999/02/22-rdf-syntax-ns#" - And the JSON node "@context[1].rdfs" should be equal to "http://www.w3.org/2000/01/rdf-schema#" - And the JSON node "@context[1].xmls" should be equal to "http://www.w3.org/2001/XMLSchema#" - And the JSON node "@context[1].owl" should be equal to "http://www.w3.org/2002/07/owl#" And the JSON node "@context[1].domain.@id" should be equal to "rdfs:domain" And the JSON node "@context[1].domain.@type" should be equal to "@id" And the JSON node "@context[1].range.@id" should be equal to "rdfs:range" @@ -63,7 +58,7 @@ Feature: Documentation support And the value of the node "hydra:property.@type" of the property "name" of the Hydra class "Dummy" is "rdf:Property" And the value of the node "hydra:property.label" of the property "name" of the Hydra class "Dummy" is "name" And the value of the node "hydra:property.domain" of the property "name" of the Hydra class "Dummy" is "#Dummy" - And the value of the node "hydra:property.range" of the property "name" of the Hydra class "Dummy" is "xmls:string" + And the value of the node "hydra:property.range" of the property "name" of the Hydra class "Dummy" is "xsd:string" And the value of the node "hydra:property.range" of the property "relatedDummy" of the Hydra class "Dummy" is "https://schema.org/Product" And the value of the node "hydra:property.owl:maxCardinality" of the property "relatedDummy" of the Hydra class "Dummy" is "1" And the value of the node "hydra:property.range" of the property "relatedDummies" of the Hydra class "Dummy" is "https://schema.org/Product" diff --git a/src/Hydra/Serializer/DocumentationNormalizer.php b/src/Hydra/Serializer/DocumentationNormalizer.php index 30eb55ae99a..3b97a8771d6 100644 --- a/src/Hydra/Serializer/DocumentationNormalizer.php +++ b/src/Hydra/Serializer/DocumentationNormalizer.php @@ -380,23 +380,23 @@ private function getRange(ApiProperty $propertyMetadata): array|string|null } if ($nativeType->isIdentifiedBy(TypeIdentifier::STRING)) { - $types[] = 'xmls:string'; + $types[] = 'xsd:string'; } if ($nativeType->isIdentifiedBy(TypeIdentifier::INT)) { - $types[] = 'xmls:integer'; + $types[] = 'xsd:integer'; } if ($nativeType->isIdentifiedBy(TypeIdentifier::FLOAT)) { - $types[] = 'xmls:decimal'; + $types[] = 'xsd:decimal'; } if ($nativeType->isIdentifiedBy(TypeIdentifier::BOOL)) { - $types[] = 'xmls:boolean'; + $types[] = 'xsd:boolean'; } if ($nativeType->isIdentifiedBy(\DateTimeInterface::class)) { - $types[] = 'xmls:dateTime'; + $types[] = 'xsd:dateTime'; } /** @var class-string|null $className */ @@ -429,23 +429,23 @@ private function getRange(ApiProperty $propertyMetadata): array|string|null switch ($type->getBuiltinType()) { case LegacyType::BUILTIN_TYPE_STRING: - if (!\in_array('xmls:string', $types, true)) { - $types[] = 'xmls:string'; + if (!\in_array('xsd:string', $types, true)) { + $types[] = 'xsd:string'; } break; case LegacyType::BUILTIN_TYPE_INT: - if (!\in_array('xmls:integer', $types, true)) { - $types[] = 'xmls:integer'; + if (!\in_array('xsd:integer', $types, true)) { + $types[] = 'xsd:integer'; } break; case LegacyType::BUILTIN_TYPE_FLOAT: - if (!\in_array('xmls:decimal', $types, true)) { - $types[] = 'xmls:decimal'; + if (!\in_array('xsd:decimal', $types, true)) { + $types[] = 'xsd:decimal'; } break; case LegacyType::BUILTIN_TYPE_BOOL: - if (!\in_array('xmls:boolean', $types, true)) { - $types[] = 'xmls:boolean'; + if (!\in_array('xsd:boolean', $types, true)) { + $types[] = 'xsd:boolean'; } break; case LegacyType::BUILTIN_TYPE_OBJECT: @@ -454,8 +454,8 @@ private function getRange(ApiProperty $propertyMetadata): array|string|null } if (is_a($className, \DateTimeInterface::class, true)) { - if (!\in_array('xmls:dateTime', $types, true)) { - $types[] = 'xmls:dateTime'; + if (!\in_array('xsd:dateTime', $types, true)) { + $types[] = 'xsd:dateTime'; } break; } @@ -557,7 +557,7 @@ private function getClasses(array $entrypointProperties, array $classes, string '@type' => 'rdf:Property', 'rdfs:label' => 'propertyPath', 'domain' => '#ConstraintViolationList', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], $hydraPrefix.'title' => 'propertyPath', $hydraPrefix.'description' => 'The property path of the violation', @@ -571,7 +571,7 @@ private function getClasses(array $entrypointProperties, array $classes, string '@type' => 'rdf:Property', 'rdfs:label' => 'message', 'domain' => '#ConstraintViolationList', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], $hydraPrefix.'title' => 'message', $hydraPrefix.'description' => 'The message associated with the violation', @@ -664,11 +664,6 @@ private function getContext(string $hydraPrefix = ContextBuilder::HYDRA_PREFIX): HYDRA_CONTEXT, [ '@vocab' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT], UrlGeneratorInterface::ABS_URL).'#', - 'hydra' => ContextBuilderInterface::HYDRA_NS, - 'rdf' => ContextBuilderInterface::RDF_NS, - 'rdfs' => ContextBuilderInterface::RDFS_NS, - 'xmls' => ContextBuilderInterface::XML_NS, - 'owl' => ContextBuilderInterface::OWL_NS, 'schema' => ContextBuilderInterface::SCHEMA_ORG_NS, 'domain' => ['@id' => 'rdfs:domain', '@type' => '@id'], 'range' => ['@id' => 'rdfs:range', '@type' => '@id'], diff --git a/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php b/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php index d04c92cb3b7..75d0d04f503 100644 --- a/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php +++ b/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php @@ -113,11 +113,6 @@ private function doTestNormalize($resourceMetadataFactory = null): void HYDRA_CONTEXT, [ '@vocab' => '/doc#', - 'hydra' => 'http://www.w3.org/ns/hydra/core#', - 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', - 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', - 'xmls' => 'http://www.w3.org/2001/XMLSchema#', - 'owl' => 'http://www.w3.org/2002/07/owl#', 'schema' => 'https://schema.org/', 'domain' => [ '@id' => 'rdfs:domain', @@ -151,7 +146,7 @@ private function doTestNormalize($resourceMetadataFactory = null): void '@type' => 'rdf:Property', 'label' => 'name', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'hydra:title' => 'name', 'hydra:required' => false, @@ -181,7 +176,7 @@ private function doTestNormalize($resourceMetadataFactory = null): void '@type' => 'rdf:Property', 'label' => 'name_converted', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'hydra:title' => 'name_converted', 'hydra:required' => false, @@ -310,7 +305,7 @@ private function doTestNormalize($resourceMetadataFactory = null): void '@type' => 'rdf:Property', 'rdfs:label' => 'propertyPath', 'domain' => '#ConstraintViolationList', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'hydra:title' => 'propertyPath', 'hydra:description' => 'The property path of the violation', @@ -324,7 +319,7 @@ private function doTestNormalize($resourceMetadataFactory = null): void '@type' => 'rdf:Property', 'rdfs:label' => 'message', 'domain' => '#ConstraintViolationList', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'hydra:title' => 'message', 'hydra:description' => 'The message associated with the violation', @@ -400,7 +395,7 @@ public function testNormalizeInputOutputClass(): void '@type' => 'rdf:Property', 'label' => 'a', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'hydra:title' => 'a', 'hydra:required' => false, @@ -415,7 +410,7 @@ public function testNormalizeInputOutputClass(): void '@type' => 'rdf:Property', 'label' => 'b', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'hydra:title' => 'b', 'hydra:required' => false, @@ -430,7 +425,7 @@ public function testNormalizeInputOutputClass(): void '@type' => 'rdf:Property', 'label' => 'c', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'hydra:title' => 'c', 'hydra:required' => false, @@ -445,7 +440,7 @@ public function testNormalizeInputOutputClass(): void '@type' => 'rdf:Property', 'label' => 'd', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'hydra:title' => 'd', 'hydra:required' => false, @@ -536,7 +531,7 @@ public function testHasHydraContext(): void '@type' => 'https://schema.org/Enumeration', 'label' => 'name', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], $documentationNormalizer->normalize($documentation)['hydra:supportedClass'][0]['hydra:supportedProperty'][0]['hydra:property']); } @@ -600,11 +595,6 @@ public function testNormalizeWithoutPrefix(): void HYDRA_CONTEXT, [ '@vocab' => '/doc#', - 'hydra' => 'http://www.w3.org/ns/hydra/core#', - 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', - 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', - 'xmls' => 'http://www.w3.org/2001/XMLSchema#', - 'owl' => 'http://www.w3.org/2002/07/owl#', 'schema' => 'https://schema.org/', 'domain' => [ '@id' => 'rdfs:domain', @@ -638,7 +628,7 @@ public function testNormalizeWithoutPrefix(): void '@type' => 'rdf:Property', 'label' => 'name', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'title' => 'name', 'required' => false, @@ -668,7 +658,7 @@ public function testNormalizeWithoutPrefix(): void '@type' => 'rdf:Property', 'label' => 'name_converted', 'domain' => '#dummy', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'title' => 'name_converted', 'required' => false, @@ -797,7 +787,7 @@ public function testNormalizeWithoutPrefix(): void '@type' => 'rdf:Property', 'rdfs:label' => 'propertyPath', 'domain' => '#ConstraintViolationList', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'title' => 'propertyPath', 'description' => 'The property path of the violation', @@ -811,7 +801,7 @@ public function testNormalizeWithoutPrefix(): void '@type' => 'rdf:Property', 'rdfs:label' => 'message', 'domain' => '#ConstraintViolationList', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'title' => 'message', 'description' => 'The message associated with the violation', @@ -862,11 +852,6 @@ public function testNormalizeNoEntrypointAndHideHydraOperation(): void HYDRA_CONTEXT, [ '@vocab' => '/doc#', - 'hydra' => 'http://www.w3.org/ns/hydra/core#', - 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', - 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', - 'xmls' => 'http://www.w3.org/2001/XMLSchema#', - 'owl' => 'http://www.w3.org/2002/07/owl#', 'schema' => 'https://schema.org/', 'domain' => [ '@id' => 'rdfs:domain', @@ -900,7 +885,7 @@ public function testNormalizeNoEntrypointAndHideHydraOperation(): void '@type' => 'rdf:Property', 'rdfs:label' => 'propertyPath', 'domain' => '#ConstraintViolationList', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'title' => 'propertyPath', 'description' => 'The property path of the violation', @@ -914,7 +899,7 @@ public function testNormalizeNoEntrypointAndHideHydraOperation(): void '@type' => 'rdf:Property', 'rdfs:label' => 'message', 'domain' => '#ConstraintViolationList', - 'range' => 'xmls:string', + 'range' => 'xsd:string', ], 'title' => 'message', 'description' => 'The message associated with the violation', diff --git a/tests/Fixtures/TestBundle/Document/RelationEmbedder.php b/tests/Fixtures/TestBundle/Document/RelationEmbedder.php index df28a673fc2..11893650398 100644 --- a/tests/Fixtures/TestBundle/Document/RelationEmbedder.php +++ b/tests/Fixtures/TestBundle/Document/RelationEmbedder.php @@ -27,7 +27,7 @@ * * @author Kévin Dunglas */ -#[ApiResource(operations: [new Get(), new Put(extraProperties: ['standard_put' => false]), new Delete(), new Get(routeName: 'relation_embedded.custom_get'), new Get(uriTemplate: '/api/custom-call/{id}'), new Put(uriTemplate: '/api/custom-call/{id}'), new Post(), new GetCollection()], normalizationContext: ['groups' => ['barcelona']], denormalizationContext: ['groups' => ['chicago']], hydraContext: ['@type' => 'hydra:Operation', 'hydra:title' => 'A custom operation', 'returns' => 'xmls:string'])] +#[ApiResource(operations: [new Get(), new Put(extraProperties: ['standard_put' => false]), new Delete(), new Get(routeName: 'relation_embedded.custom_get'), new Get(uriTemplate: '/api/custom-call/{id}'), new Put(uriTemplate: '/api/custom-call/{id}'), new Post(), new GetCollection()], normalizationContext: ['groups' => ['barcelona']], denormalizationContext: ['groups' => ['chicago']], hydraContext: ['@type' => 'hydra:Operation', 'hydra:title' => 'A custom operation', 'returns' => 'xsd:string'])] #[ODM\Document] class RelationEmbedder { diff --git a/tests/Fixtures/TestBundle/Entity/RelationEmbedder.php b/tests/Fixtures/TestBundle/Entity/RelationEmbedder.php index 805f932a76c..994ca9e78ac 100644 --- a/tests/Fixtures/TestBundle/Entity/RelationEmbedder.php +++ b/tests/Fixtures/TestBundle/Entity/RelationEmbedder.php @@ -27,7 +27,7 @@ * * @author Kévin Dunglas */ -#[ApiResource(operations: [new Get(), new Put(extraProperties: ['standard_put' => false]), new Delete(), new Get(routeName: 'relation_embedded.custom_get'), new Get(uriTemplate: '/api/custom-call/{id}'), new Put(uriTemplate: '/api/custom-call/{id}'), new Post(), new GetCollection()], normalizationContext: ['groups' => ['barcelona']], denormalizationContext: ['groups' => ['chicago']], hydraContext: ['@type' => 'hydra:Operation', 'hydra:title' => 'A custom operation', 'returns' => 'xmls:string'])] +#[ApiResource(operations: [new Get(), new Put(extraProperties: ['standard_put' => false]), new Delete(), new Get(routeName: 'relation_embedded.custom_get'), new Get(uriTemplate: '/api/custom-call/{id}'), new Put(uriTemplate: '/api/custom-call/{id}'), new Post(), new GetCollection()], normalizationContext: ['groups' => ['barcelona']], denormalizationContext: ['groups' => ['chicago']], hydraContext: ['@type' => 'hydra:Operation', 'hydra:title' => 'A custom operation', 'returns' => 'xsd:string'])] #[ORM\Entity] class RelationEmbedder {