Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Serializer/AbstractItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ protected function denormalizeRelation(string $attributeName, ApiProperty $prope
throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" attribute must be "array" (nested document) or "string" (IRI), "%s" given.', $attributeName, \gettype($value)), $value, ['array', 'string'], $context['deserialization_path'] ?? null, true);
}

throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('Nested documents for attribute "%s" are not allowed. Use IRIs instead.', $attributeName), $value, ['array', 'string'], $context['deserialization_path'] ?? null, true);
throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('Nested documents for attribute "%s" are not allowed. Provide an IRI, or enable nested writes by adding matching denormalization groups on the related resource (and, for to-many relations, define adder/remover methods on the parent class).', $attributeName), $value, ['array', 'string'], $context['deserialization_path'] ?? null, true);
}

private function getResourceFromIri(string $data, array $context, string $resourceClass): ?object
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/Tests/AbstractItemNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ public function testDeserializationPathForNotFoundResource(): void
public function testInnerDocumentNotAllowed(): void
{
$this->expectException(UnexpectedValueException::class);
$this->expectExceptionMessage('Nested documents for attribute "relatedDummy" are not allowed. Use IRIs instead.');
$this->expectExceptionMessage('Nested documents for attribute "relatedDummy" are not allowed. Provide an IRI, or enable nested writes by adding matching denormalization groups on the related resource (and, for to-many relations, define adder/remover methods on the parent class).');

$data = [
'relatedDummy' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Hal/ProblemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testNestedRelationDocumentReturns400Problem(): void
$body = $response->toArray(false);
$this->assertSame('/errors/400', $body['type']);
$this->assertSame('An error occurred', $body['title']);
$this->assertSame('Nested documents for attribute "relatedDummy" are not allowed. Use IRIs instead.', $body['detail']);
$this->assertSame('Nested documents for attribute "relatedDummy" are not allowed. Provide an IRI, or enable nested writes by adding matching denormalization groups on the related resource (and, for to-many relations, define adder/remover methods on the parent class).', $body['detail']);
$this->assertArrayHasKey('trace', $body);
}
}
Loading