Skip to content

Commit

Permalink
Merge branch '4.0' into fix/6685
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka authored Oct 24, 2024
2 parents 2aebef0 + ac6f667 commit 4549f82
Show file tree
Hide file tree
Showing 26 changed files with 742 additions and 158 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v4.0.5

### Bug fixes

* [4171d5f9c](https://github.com/api-platform/core/commit/4171d5f9cd41731b857c53a186270ba0626baedf) fix(graphql): register query parameter arguments with filters (#6726)
* [48ab53816](https://github.com/api-platform/core/commit/48ab53816c55e6116aa64ac81f522f4b7b9bb9f6) fix(laravel): make command writes to app instead of src (#6723)

### Features

## v4.0.4

### Bug fixes
Expand Down Expand Up @@ -143,6 +152,17 @@ Notes:

* [0d5f35683](https://github.com/api-platform/core/commit/0d5f356839eb6aa9f536044abe4affa736553e76) feat(laravel): laravel component (#5882)

## v3.4.4

### Bug fixes

* [550347867](https://github.com/api-platform/core/commit/550347867f30611b673d8df99f65186d013919dd) fix(graphql): register query parameter arguments with filters (#6727)
* [99262dce7](https://github.com/api-platform/core/commit/99262dce739800bd841c95e026848b587ba25801) fix(jsonschema): handle @id when genId is false (#6716)
* [ad5efa535](https://github.com/api-platform/core/commit/ad5efa535a4dcbaad64ecff89514eaa6e07f5b7c) fix: multiple parameter provider #6673 (#6732)
* [d34cd7be8](https://github.com/api-platform/core/commit/d34cd7be8e7a12fd08a8b10270a614c06c10aa89) fix: use stateOptions when retrieving a Parameter filter (#6728)
* [e7fb04fab](https://github.com/api-platform/core/commit/e7fb04fab05bc077e2dbeb0fa0fc2c1d28c96105) fix(symfony): fetch api-platform/symfony version debug bar (#6722)
* [e96623ebf](https://github.com/api-platform/core/commit/e96623ebfd8691ba943bdb56a4d91e160497a311) fix(jsonld): prefix error @type with hydra: (#6721)

## v3.4.3

### Bug fixes
Expand Down
31 changes: 14 additions & 17 deletions features/hydra/docs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,19 @@ Feature: Documentation support
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
# Context
And the JSON node "@context.@vocab" should be equal to "http://example.com/docs.jsonld#"
And the JSON node "@context.hydra" should be equal to "http://www.w3.org/ns/hydra/core#"
And the JSON node "@context.rdf" should be equal to "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
And the JSON node "@context.rdfs" should be equal to "http://www.w3.org/2000/01/rdf-schema#"
And the JSON node "@context.xmls" should be equal to "http://www.w3.org/2001/XMLSchema#"
And the JSON node "@context.owl" should be equal to "http://www.w3.org/2002/07/owl#"
And the JSON node "@context.domain.@id" should be equal to "rdfs:domain"
And the JSON node "@context.domain.@type" should be equal to "@id"
And the JSON node "@context.range.@id" should be equal to "rdfs:range"
And the JSON node "@context.range.@type" should be equal to "@id"
And the JSON node "@context.subClassOf.@id" should be equal to "rdfs:subClassOf"
And the JSON node "@context.subClassOf.@type" should be equal to "@id"
And the JSON node "@context.expects.@id" should be equal to "hydra:expects"
And the JSON node "@context.expects.@type" should be equal to "@id"
And the JSON node "@context.returns.@id" should be equal to "hydra:returns"
And the JSON node "@context.returns.@type" should be equal to "@id"
And the JSON node "@context[0]" should be equal to "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"
And the JSON node "@context[1].range.@type" should be equal to "@id"
And the JSON node "@context[1].subClassOf.@id" should be equal to "rdfs:subClassOf"
And the JSON node "@context[1].subClassOf.@type" should be equal to "@id"
# Root properties
And the JSON node "@id" should be equal to "/docs.jsonld"
And the JSON node "hydra:title" should be equal to "My Dummy API"
Expand Down Expand Up @@ -79,7 +76,7 @@ Feature: Documentation support
And the value of the node "hydra:method" of the operation "GET" of the Hydra class "Dummy" is "GET"
And the value of the node "hydra:title" of the operation "GET" of the Hydra class "Dummy" is "Retrieves a Dummy resource."
And the value of the node "rdfs:label" of the operation "GET" of the Hydra class "Dummy" is "Retrieves a Dummy resource."
And the value of the node "returns" of the operation "GET" of the Hydra class "Dummy" is "#Dummy"
And the value of the node "returns" of the operation "GET" of the Hydra class "Dummy" is "Dummy"
And the value of the node "hydra:title" of the operation "PUT" of the Hydra class "Dummy" is "Replaces the Dummy resource."
And the value of the node "hydra:title" of the operation "DELETE" of the Hydra class "Dummy" is "Deletes the Dummy resource."
And the value of the node "returns" of the operation "DELETE" of the Hydra class "Dummy" is "owl:Nothing"
Expand Down
2 changes: 1 addition & 1 deletion features/main/relation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ Feature: Relations support
"properties": {
"@type": {
"type": "string",
"pattern": "^Error$"
"pattern": "^hydra:Error$"
},
"title": {
"type": "string",
Expand Down
4 changes: 2 additions & 2 deletions features/mongodb/filters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Filters on collections
And the response should be in JSON
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "title" should be equal to "An error occurred"
And the JSON node "description" should be equal to "Cannot use reference 'badFourthLevel' in class 'ThirdLevel' for lookup or graphLookup: dbRef references are not supported."
And the JSON node "trace" should exist
Expand All @@ -23,7 +23,7 @@ Feature: Filters on collections
And the response should be in JSON
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "title" should be equal to "An error occurred"
And the JSON node "description" should be equal to "Cannot use reference 'badThirdLevel' in class 'FourthLevel' for lookup or graphLookup: dbRef references are not supported."
And the JSON node "trace" should exist
10 changes: 5 additions & 5 deletions features/security/strong_typing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Feature: Handle properly invalid data submitted to the API
And the response should be in JSON
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "title" should be equal to "An error occurred"
And the JSON node "description" should be equal to 'The type of the "name" attribute must be "string", "NULL" given.'

Expand All @@ -71,7 +71,7 @@ Feature: Handle properly invalid data submitted to the API
And the response should be in JSON
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "title" should be equal to "An error occurred"
And the JSON node "description" should be equal to 'Invalid IRI "1".'
And the JSON node "trace" should exist
Expand Down Expand Up @@ -102,7 +102,7 @@ Feature: Handle properly invalid data submitted to the API
And the response should be in JSON
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "title" should be equal to "An error occurred"
And the JSON node "description" should be equal to 'The type of the "relatedDummies" attribute must be "array", "string" given.'
And the JSON node "trace" should exist
Expand All @@ -120,7 +120,7 @@ Feature: Handle properly invalid data submitted to the API
And the response should be in JSON
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "title" should be equal to "An error occurred"
And the JSON node "description" should be equal to 'The type of the key "a" must be "int", "string" given.'

Expand All @@ -136,7 +136,7 @@ Feature: Handle properly invalid data submitted to the API
And the response should be in JSON
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "title" should be equal to "An error occurred"
And the JSON node "description" should be equal to 'The type of the "name" attribute must be "string", "integer" given.'

Expand Down
2 changes: 1 addition & 1 deletion features/serializer/vo_relations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Feature: Value object as ApiResource
"properties": {
"@type": {
"type": "string",
"pattern": "^Error$"
"pattern": "^hydra:Error$"
},
"title": {
"type": "string",
Expand Down
31 changes: 16 additions & 15 deletions src/Hydra/Serializer/DocumentationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
}

$shortName = $resourceMetadata->getShortName();

$prefixedShortName = $resourceMetadata->getTypes()[0] ?? "#$shortName";
$this->populateEntrypointProperties($resourceMetadata, $shortName, $prefixedShortName, $entrypointProperties, $hydraPrefix, $resourceMetadataCollection);
$classes[] = $this->getClass($resourceClass, $resourceMetadata, $shortName, $prefixedShortName, $context, $hydraPrefix, $resourceMetadataCollection);
Expand Down Expand Up @@ -243,8 +244,7 @@ private function getHydraOperations(bool $collection, ?ResourceMetadataCollectio
if (('POST' === $operation->getMethod() || $operation instanceof CollectionOperationInterface) !== $collection) {
continue;
}

$hydraOperations[] = $this->getHydraOperation($operation, $operation->getTypes()[0] ?? "#{$operation->getShortName()}", $hydraPrefix);
$hydraOperations[] = $this->getHydraOperation($operation, $operation->getShortName(), $hydraPrefix);
}
}

Expand Down Expand Up @@ -430,7 +430,7 @@ private function getClasses(array $entrypointProperties, array $classes, string
'@type' => $hydraPrefix.'Operation',
$hydraPrefix.'method' => 'GET',
'rdfs:label' => 'The API entrypoint.',
'returns' => '#EntryPoint',
'returns' => 'EntryPoint',
],
];

Expand Down Expand Up @@ -573,18 +573,19 @@ private function computeDoc(Documentation $object, array $classes, string $hydra
private function getContext(string $hydraPrefix = ContextBuilder::HYDRA_PREFIX): array
{
return [
'@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'],
'subClassOf' => ['@id' => 'rdfs:subClassOf', '@type' => '@id'],
'expects' => ['@id' => $hydraPrefix.'expects', '@type' => '@id'],
'returns' => ['@id' => $hydraPrefix.'returns', '@type' => '@id'],
ContextBuilderInterface::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'],
'subClassOf' => ['@id' => 'rdfs:subClassOf', '@type' => '@id'],
],
];
}

Expand Down
Loading

0 comments on commit 4549f82

Please sign in to comment.