From 3433a5e45f37eba37ce78bfe60218bcca3e5c5bd Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:08:12 +0200 Subject: [PATCH 1/4] fix: remove "hydra:" remaining prefix --- src/JsonLd/ContextBuilder.php | 3 ++- src/State/ApiResource/Error.php | 10 +--------- src/Validator/Exception/ValidationException.php | 10 +--------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/JsonLd/ContextBuilder.php b/src/JsonLd/ContextBuilder.php index 5cb591d0fa..0fe1063636 100644 --- a/src/JsonLd/ContextBuilder.php +++ b/src/JsonLd/ContextBuilder.php @@ -14,6 +14,7 @@ namespace ApiPlatform\JsonLd; use ApiPlatform\JsonLd\Serializer\HydraPrefixTrait; +use ApiPlatform\Metadata\Error; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\IriConverterInterface; @@ -184,7 +185,7 @@ private function getResourceContextWithShortname(string $resourceClass, int $ref } } - if (false === ($this->defaultContext[self::HYDRA_CONTEXT_HAS_PREFIX] ?? true)) { + if (false === ($this->defaultContext[self::HYDRA_CONTEXT_HAS_PREFIX] ?? true) || $operation instanceof Error) { return ['http://www.w3.org/ns/hydra/context.jsonld', $context]; } diff --git a/src/State/ApiResource/Error.php b/src/State/ApiResource/Error.php index 43f65a25ae..e101eb0952 100644 --- a/src/State/ApiResource/Error.php +++ b/src/State/ApiResource/Error.php @@ -25,7 +25,6 @@ use Symfony\Component\WebLink\Link; #[ErrorResource( - types: ['hydra:Error'], openapi: false, uriVariables: ['status'], uriTemplate: '/errors/{status}', @@ -98,14 +97,7 @@ public function __construct( #[Groups(['trace'])] public ?array $originalTrace = null; - #[SerializedName('hydra:title')] - #[Groups(['jsonld'])] - public function getHydraTitle(): ?string - { - return $this->title; - } - - #[SerializedName('hydra:description')] + #[SerializedName('description')] #[Groups(['jsonld'])] public function getHydraDescription(): ?string { diff --git a/src/Validator/Exception/ValidationException.php b/src/Validator/Exception/ValidationException.php index 26f4c2f1fb..98117463ff 100644 --- a/src/Validator/Exception/ValidationException.php +++ b/src/Validator/Exception/ValidationException.php @@ -108,16 +108,8 @@ public function getId(): string return $id; } - #[SerializedName('hydra:title')] #[Groups(['jsonld'])] - public function getHydraTitle(): string - { - return $this->errorTitle ?? 'An error occurred'; - } - - #[Groups(['jsonld'])] - #[SerializedName('hydra:description')] - public function getHydraDescription(): string + public function getDescription(): string { return $this->detail; } From 71a2592fbef930cd51e91ca8042f9a12d32e3af3 Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:15:06 +0200 Subject: [PATCH 2/4] fix: remove "hydra:description" and "hydra:title" remaining from guides --- docs/guides/validate-incoming-data.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guides/validate-incoming-data.php b/docs/guides/validate-incoming-data.php index 2b8bbed03b..afefd71189 100644 --- a/docs/guides/validate-incoming-data.php +++ b/docs/guides/validate-incoming-data.php @@ -139,8 +139,8 @@ public function testValidation(): void // { // "@context": "/contexts/ConstraintViolationList", // "@type": "ConstraintViolationList", - // "hydra:title": "An error occurred", - // "hydra:description": "properties: The product must have the minimal properties required (\"description\", \"price\")", + // "title": "An error occurred", + // "description": "properties: The product must have the minimal properties required (\"description\", \"price\")", // "violations": [ // { // "propertyPath": "properties", @@ -151,7 +151,7 @@ public function testValidation(): void // ``` $this->assertResponseStatusCodeSame(422); $this->assertJsonContains([ - 'hydra:description' => 'properties: The product must have the minimal properties required ("description", "price")', + 'description' => 'properties: The product must have the minimal properties required ("description", "price")', 'title' => 'An error occurred', 'violations' => [ ['propertyPath' => 'properties', 'message' => 'The product must have the minimal properties required ("description", "price")'], From a7ff7515fd3e266a35dbe9343b378e5b47f65049 Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:15:22 +0200 Subject: [PATCH 3/4] fix: remove "hydra:description" and "hydra:title" remaining from behat tests --- features/hydra/collection.feature | 2 +- features/hydra/error.feature | 16 +++++----- features/hydra/error_legacy.feature | 28 ++++++++--------- features/jsonld/input_output.feature | 2 +- features/main/attribute_resource.feature | 2 +- features/main/crud.feature | 4 +-- features/main/not_exposed.feature | 4 +-- features/main/relation.feature | 12 ++++---- features/main/union_intersect_types.feature | 2 +- features/main/validation.feature | 14 ++++----- features/mongodb/filters.feature | 12 ++++---- features/security/strong_typing.feature | 30 +++++++++---------- .../validate_incoming_content-types.feature | 2 +- features/serializer/vo_relations.feature | 10 +++---- 14 files changed, 70 insertions(+), 70 deletions(-) diff --git a/features/hydra/collection.feature b/features/hydra/collection.feature index 2ba5de7f1b..06e8bda89d 100644 --- a/features/hydra/collection.feature +++ b/features/hydra/collection.feature @@ -479,7 +479,7 @@ Feature: Collections support When I send a "GET" request to "/dummies?itemsPerPage=0&page=2" Then the response status code should be 400 - And the JSON node "hydra:description" should be equal to "Page should not be greater than 1 if limit is equal to 0" + And the JSON node "description" should be equal to "Page should not be greater than 1 if limit is equal to 0" Scenario: Cursor-based pagination with an empty collection When I send a "GET" request to "/so_manies" diff --git a/features/hydra/error.feature b/features/hydra/error.feature index 85e574e43f..68f1056d21 100644 --- a/features/hydra/error.feature +++ b/features/hydra/error.feature @@ -17,9 +17,9 @@ Feature: Error handling And the header "Link" should contain '; rel="http://www.w3.org/ns/json-ld#error"' And the JSON node "type" should exist And the JSON node "title" should be equal to "An error occurred" - And the JSON node "hydra:title" should be equal to "An error occurred" + And the JSON node "title" should be equal to "An error occurred" And the JSON node "detail" should exist - And the JSON node "hydra:description" should exist + And the JSON node "description" should exist And the JSON node "trace" should exist And the JSON node "status" should exist And the JSON node "@context" should not exist @@ -47,8 +47,8 @@ Feature: Error handling } ], "detail": "name: This value should not be blank.", - "hydra:title": "An error occurred", - "hydra:description": "name: This value should not be blank.", + "title": "An error occurred", + "description": "name: This value should not be blank.", "type": "/validation_errors/c1051bb4-d103-4f74-8988-acbcafc7fdc3", "title": "An error occurred" } @@ -82,9 +82,9 @@ Feature: Error handling And the JSON node "@context" should not exist And the JSON node "type" should exist And the JSON node "title" should be equal to "An error occurred" - And the JSON node "hydra:title" should be equal to "An error occurred" + And the JSON node "title" should be equal to "An error occurred" And the JSON node "detail" should exist - And the JSON node "hydra:description" should exist + And the JSON node "description" should exist Scenario: Get an rfc 7807 bad method error When I add "Content-Type" header equal to "application/ld+json" @@ -100,9 +100,9 @@ Feature: Error handling And the JSON node "@context" should not exist And the JSON node "type" should exist And the JSON node "title" should be equal to "An error occurred" - And the JSON node "hydra:title" should be equal to "An error occurred" + And the JSON node "title" should be equal to "An error occurred" And the JSON node "detail" should exist - And the JSON node "hydra:description" should exist + And the JSON node "description" should exist Scenario: Get an rfc 7807 validation error When I add "Content-Type" header equal to "application/ld+json" diff --git a/features/hydra/error_legacy.feature b/features/hydra/error_legacy.feature index 9b97476e31..6a38deb818 100644 --- a/features/hydra/error_legacy.feature +++ b/features/hydra/error_legacy.feature @@ -17,8 +17,8 @@ Feature: Error handling { "@context": "/contexts/ConstraintViolationList", "@type": "ConstraintViolationList", - "hydra:title": "An error occurred", - "hydra:description": "name: This value should not be blank.", + "title": "An error occurred", + "description": "name: This value should not be blank.", "violations": [ { "propertyPath": "name", @@ -44,9 +44,9 @@ Feature: Error handling And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should be equal to 'Nested documents for attribute "relatedDummy" are not allowed. Use IRIs instead.' + And the JSON node "@type" should be equal to "Error" + And the JSON node "title" should be equal to "An error occurred" + And the JSON node "description" should be equal to 'Nested documents for attribute "relatedDummy" are not allowed. Use IRIs instead.' And the JSON node "trace" should exist Scenario: Get an error during deserialization of collection @@ -64,9 +64,9 @@ Feature: Error handling And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should be equal to 'Nested documents for attribute "relatedDummies" are not allowed. Use IRIs instead.' + And the JSON node "@type" should be equal to "Error" + And the JSON node "title" should be equal to "An error occurred" + And the JSON node "description" should be equal to 'Nested documents for attribute "relatedDummies" are not allowed. Use IRIs instead.' And the JSON node "trace" should exist Scenario: Get an error because of an invalid JSON @@ -81,9 +81,9 @@ Feature: Error handling And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should exist + And the JSON node "@type" should be equal to "Error" + And the JSON node "title" should be equal to "An error occurred" + And the JSON node "description" should exist And the JSON node "trace" should exist Scenario: Get an error during update of an existing resource with a non-allowed update operation @@ -99,9 +99,9 @@ Feature: Error handling And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should be equal to "Update is not allowed for this operation." + And the JSON node "@type" should be equal to "Error" + And the JSON node "title" should be equal to "An error occurred" + And the JSON node "description" should be equal to "Update is not allowed for this operation." And the JSON node "trace" should exist @createSchema diff --git a/features/jsonld/input_output.feature b/features/jsonld/input_output.feature index 73b1ba6e34..6f65fa71c7 100644 --- a/features/jsonld/input_output.feature +++ b/features/jsonld/input_output.feature @@ -309,7 +309,7 @@ Feature: JSON-LD DTO input and output """ Then the response status code should be 400 And the response should be in JSON - And the JSON node "hydra:description" should be equal to "The input data is misformatted." + And the JSON node "description" should be equal to "The input data is misformatted." @!mongodb Scenario: Reset password through an input DTO without DataTransformer diff --git a/features/main/attribute_resource.feature b/features/main/attribute_resource.feature index 90a8bff166..016e3e9997 100644 --- a/features/main/attribute_resource.feature +++ b/features/main/attribute_resource.feature @@ -100,7 +100,7 @@ Feature: Resource attributes And the response should be in JSON And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8" And the header "Link" should contain '; rel="http://www.w3.org/ns/json-ld#error"' - And the JSON node "hydra:description" should be equal to 'Unable to generate an IRI for the item of type "ApiPlatform\Tests\Fixtures\TestBundle\Entity\IncompleteUriVariableConfigured"' + And the JSON node "description" should be equal to 'Unable to generate an IRI for the item of type "ApiPlatform\Tests\Fixtures\TestBundle\Entity\IncompleteUriVariableConfigured"' Scenario: Uri variables with Post operation When I add "Content-Type" header equal to "application/ld+json" diff --git a/features/main/crud.feature b/features/main/crud.feature index 1fc310d63b..db37c7a161 100644 --- a/features/main/crud.feature +++ b/features/main/crud.feature @@ -95,7 +95,7 @@ Feature: Create-Retrieve-Update-Delete When I add "Content-Type" header equal to "application/ld+json" And I send a "POST" request to "/dummies" Then the response status code should be 400 - And the JSON node "hydra:description" should be equal to "Syntax error" + And the JSON node "description" should be equal to "Syntax error" Scenario: Get a not found exception When I send a "GET" request to "/dummies/42" @@ -551,7 +551,7 @@ Feature: Create-Retrieve-Update-Delete When I add "Content-Type" header equal to "application/ld+json" And I send a "PUT" request to "/dummies/1" Then the response status code should be 400 - And the JSON node "hydra:description" should be equal to "Syntax error" + And the JSON node "description" should be equal to "Syntax error" Scenario: Delete a resource When I send a "DELETE" request to "/dummies/1" diff --git a/features/main/not_exposed.feature b/features/main/not_exposed.feature index aa6cb25279..40cca96bea 100644 --- a/features/main/not_exposed.feature +++ b/features/main/not_exposed.feature @@ -171,9 +171,9 @@ Feature: Expose only a collection of objects When I send a "GET" request to "" Then the response status code should be 404 And the response should be in JSON - And the JSON node "hydra:description" should be equal to "" + And the JSON node "description" should be equal to "" Examples: - | uri | hydra:description | + | uri | description | | /.well-known/genid/12345 | This route is not exposed on purpose. It generates an IRI for a collection resource without identifier nor item operation. | | /tables/12345 | This route does not aim to be called. | | /forks/12345 | This route does not aim to be called. | diff --git a/features/main/relation.feature b/features/main/relation.feature index 07d5050cda..206a4789ff 100644 --- a/features/main/relation.feature +++ b/features/main/relation.feature @@ -472,7 +472,7 @@ Feature: Relations support Then the response status code should be 400 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 "hydra:description" should contain 'Invalid IRI "certainly not an IRI".' + And the JSON node "description" should contain 'Invalid IRI "certainly not an IRI".' Scenario: Passing an invalid type to a relation When I add "Content-Type" header equal to "application/ld+json" @@ -493,20 +493,20 @@ Feature: Relations support "properties": { "@type": { "type": "string", - "pattern": "^hydra:Error$" + "pattern": "^Error$" }, - "hydra:title": { + "title": { "type": "string", "pattern": "^An error occurred$" }, - "hydra:description": { + "description": { "pattern": "^The type of the \"ApiPlatform\\\\Tests\\\\Fixtures\\\\TestBundle\\\\(Document|Entity)\\\\RelatedDummy\" resource must be \"array\" \\(nested document\\) or \"string\" \\(IRI\\), \"integer\" given.$" } }, "required": [ "@type", - "hydra:title", - "hydra:description" + "title", + "description" ] } """ diff --git a/features/main/union_intersect_types.feature b/features/main/union_intersect_types.feature index 97e415f60e..d11edd4200 100644 --- a/features/main/union_intersect_types.feature +++ b/features/main/union_intersect_types.feature @@ -118,4 +118,4 @@ Feature: Union/Intersect types Then the response status code should be 400 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 "hydra:description" should be equal to 'Could not denormalize object of type "ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5452\ActivableInterface", no supporting normalizer found.' + And the JSON node "description" should be equal to 'Could not denormalize object of type "ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5452\ActivableInterface", no supporting normalizer found.' diff --git a/features/main/validation.feature b/features/main/validation.feature index b8ab1feb8a..c345c84121 100644 --- a/features/main/validation.feature +++ b/features/main/validation.feature @@ -31,8 +31,8 @@ Feature: Using validations groups { "@context": "/contexts/ConstraintViolationList", "@type": "ConstraintViolationList", - "hydra:title": "An error occurred", - "hydra:description": "name: This value should not be null.", + "title": "An error occurred", + "description": "name: This value should not be null.", "violations": [ { "propertyPath": "name", @@ -60,8 +60,8 @@ Feature: Using validations groups { "@context": "/contexts/ConstraintViolationList", "@type": "ConstraintViolationList", - "hydra:title": "An error occurred", - "hydra:description": "title: This value should not be null.", + "title": "An error occurred", + "description": "title: This value should not be null.", "violations": [ { "propertyPath": "title", @@ -87,7 +87,7 @@ Feature: Using validations groups And the JSON node "violations[0].message" should be equal to "This value should not be null." And the JSON node "violations[0].propertyPath" should be equal to "test" And the JSON node "detail" should be equal to "test: This value should not be null." - And the JSON node "hydra:description" should be equal to "test: This value should not be null." + And the JSON node "description" should be equal to "test: This value should not be null." And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8" @!mongodb @@ -113,8 +113,8 @@ Feature: Using validations groups { "@context": "/contexts/ConstraintViolationList", "@type": "ConstraintViolationList", - "hydra:title": "An error occurred", - "hydra:description": "This value should be of type unknown.\nqux: This value should be of type string.\nfoo: This value should be of type bool.\nbar: This value should be of type int.\nuuid: This value should be of type uuid.\nrelatedDummy: This value should be of type array|string.\nrelatedDummies: This value should be of type array.", + "title": "An error occurred", + "description": "This value should be of type unknown.\nqux: This value should be of type string.\nfoo: This value should be of type bool.\nbar: This value should be of type int.\nuuid: This value should be of type uuid.\nrelatedDummy: This value should be of type array|string.\nrelatedDummies: This value should be of type array.", "violations": [ { "propertyPath": "", diff --git a/features/mongodb/filters.feature b/features/mongodb/filters.feature index 9e89239215..bb727bd63b 100644 --- a/features/mongodb/filters.feature +++ b/features/mongodb/filters.feature @@ -12,9 +12,9 @@ Feature: Filters on collections And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra: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 "@type" should be equal to "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 Scenario: Error when getting collection with nested properties if references are not correctly stored (not owning side) @@ -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/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra: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 "@type" should be equal to "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 diff --git a/features/security/strong_typing.feature b/features/security/strong_typing.feature index 3d4b7599a6..bd957684ff 100644 --- a/features/security/strong_typing.feature +++ b/features/security/strong_typing.feature @@ -54,9 +54,9 @@ 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/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should be equal to 'The type of the "name" attribute must be "string", "NULL" given.' + And the JSON node "@type" should be equal to "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.' Scenario: Create a resource with wrong value type for relation When I add "Content-Type" header equal to "application/ld+json" @@ -71,9 +71,9 @@ 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/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should be equal to 'Invalid IRI "1".' + And the JSON node "@type" should be equal to "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 Scenario: Ignore invalid dates @@ -102,9 +102,9 @@ 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/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should be equal to 'The type of the "relatedDummies" attribute must be "array", "string" given.' + And the JSON node "@type" should be equal to "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 Scenario: Send an object where an array is expected @@ -120,9 +120,9 @@ 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/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should be equal to 'The type of the key "a" must be "int", "string" given.' + And the JSON node "@type" should be equal to "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.' Scenario: Send a scalar having the bad type When I add "Content-Type" header equal to "application/ld+json" @@ -136,9 +136,9 @@ 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/ld+json; charset=utf-8" And the JSON node "@context" should be equal to "/contexts/Error" - And the JSON node "@type" should be equal to "hydra:Error" - And the JSON node "hydra:title" should be equal to "An error occurred" - And the JSON node "hydra:description" should be equal to 'The type of the "name" attribute must be "string", "integer" given.' + And the JSON node "@type" should be equal to "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.' Scenario: According to the JSON spec, allow numbers without explicit floating point for JSON formats When I add "Content-Type" header equal to "application/ld+json" diff --git a/features/security/validate_incoming_content-types.feature b/features/security/validate_incoming_content-types.feature index 993352428c..e18b7ab4a0 100644 --- a/features/security/validate_incoming_content-types.feature +++ b/features/security/validate_incoming_content-types.feature @@ -14,4 +14,4 @@ Feature: Validate incoming content type """ Then the response status code should be 415 And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" - And the JSON node "hydra:description" should be equal to 'The content-type "text/plain" is not supported. Supported MIME types are "application/ld+json", "application/hal+json", "application/vnd.api+json", "application/xml", "text/xml", "application/json", "text/html", "application/graphql", "multipart/form-data".' + And the JSON node "description" should be equal to 'The content-type "text/plain" is not supported. Supported MIME types are "application/ld+json", "application/hal+json", "application/vnd.api+json", "application/xml", "text/xml", "application/json", "text/html", "application/graphql", "multipart/form-data".' diff --git a/features/serializer/vo_relations.feature b/features/serializer/vo_relations.feature index 0a3ba73c37..ccf4943981 100644 --- a/features/serializer/vo_relations.feature +++ b/features/serializer/vo_relations.feature @@ -148,20 +148,20 @@ Feature: Value object as ApiResource "properties": { "@type": { "type": "string", - "pattern": "^hydra:Error$" + "pattern": "^Error$" }, - "hydra:title": { + "title": { "type": "string", "pattern": "^An error occurred$" }, - "hydra:description": { + "description": { "pattern": "^Cannot create an instance of \"ApiPlatform\\\\Tests\\\\Fixtures\\\\TestBundle\\\\(Document|Entity)\\\\VoDummyCar\" from serialized data because its constructor requires the following parameters to be present : \"\\$drivers\".$" } }, "required": [ "@type", - "hydra:title", - "hydra:description" + "title", + "description" ] } """ From 00f215c0a67a0a6f27245a16cb2ccfe2fc976d63 Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:44:26 +0200 Subject: [PATCH 4/4] fix: fix review --- src/State/ApiResource/Error.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/State/ApiResource/Error.php b/src/State/ApiResource/Error.php index e101eb0952..2ad7ebfa65 100644 --- a/src/State/ApiResource/Error.php +++ b/src/State/ApiResource/Error.php @@ -97,14 +97,7 @@ public function __construct( #[Groups(['trace'])] public ?array $originalTrace = null; - #[SerializedName('description')] #[Groups(['jsonld'])] - public function getHydraDescription(): ?string - { - return $this->detail; - } - - #[SerializedName('description')] public function getDescription(): ?string { return $this->detail;