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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2.5.5

* GraphQL: Do not allow empty cursor values on `before` or `after`
* OpenAPI: Fix required fields by keeping them required even if they are not writable to allow valid read types generation on client side (#3381)

## 2.5.4

Expand Down
4 changes: 0 additions & 4 deletions src/Metadata/Property/PropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ public function withWritable(bool $writable): self
*/
public function isRequired(): ?bool
{
if (true === $this->required && false === $this->writable) {
return false;
}

return $this->required;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Bridge/NelmioApiDoc/Parser/ApiPlatformParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function testSupportsAttributeNormalization()
$this->assertEquals([
'id' => [
'dataType' => DataTypes::INTEGER,
'required' => false,
'required' => true,
'description' => 'The id.',
'readonly' => true,
],
Expand Down Expand Up @@ -262,7 +262,7 @@ public function testParse()
$this->assertEquals([
'id' => [
'dataType' => DataTypes::INTEGER,
'required' => false,
'required' => true,
'description' => 'The id.',
'readonly' => true,
],
Expand Down Expand Up @@ -399,7 +399,7 @@ public function testParseRelation()
'children' => [
'id' => [
'dataType' => DataTypes::INTEGER,
'required' => false,
'required' => true,
'description' => null,
'readonly' => true,
],
Expand Down
4 changes: 2 additions & 2 deletions tests/Metadata/Property/PropertyMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public function testValueObject()
$this->assertTrue($newMetadata->isInitializable());
}

public function testShouldReturnRequiredFalseWhenRequiredTrueIsSetButMaskedByWritableFalse()
public function testShouldReturnRequiredTrueEvenIfWritableFalseSoClientCanAssumeValueCannotBeUndefinedOnReadOperation()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should remove / rephrase this test

{
$metadata = new PropertyMetadata();

$metadata = $metadata->withRequired(true);
$metadata = $metadata->withWritable(false);

$this->assertFalse($metadata->isRequired());
$this->assertTrue($metadata->isRequired());
}

public function testShouldReturnPreviouslySetRequiredTrueWhenWritableFalseUnmasked()
Expand Down