Skip to content

Commit 824f77e

Browse files
committed
chore(api): fixed swagger doc for attributes
1 parent 8261daf commit 824f77e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/ApiPlatform/Resources/Attribute/Attribute.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class Attribute
9292
public int $attributeGroupId;
9393

9494
#[LocalizedValue]
95+
#[Assert\NotBlank(groups: ['Create'])]
9596
#[DefaultLanguage(groups: ['Create'], fieldName: 'names')]
9697
#[DefaultLanguage(groups: ['Update'], fieldName: 'names', allowNull: true)]
9798
#[Assert\All(constraints: [
@@ -107,16 +108,14 @@ class Attribute
107108
#[Assert\NotBlank(allowNull: true)]
108109
public array $shopIds;
109110

110-
public int $position;
111-
112111
public const QUERY_MAPPING = [
113112
'[localizedNames]' => '[names]',
114113
'[name]' => '[names]',
115114
'[associatedShopIds]' => '[shopIds]',
116115
];
117116

118117
public const CREATE_COMMAND_MAPPING = [
119-
'[names]' => '[localizedValue]',
118+
'[names]' => '[localizedNames]',
120119
'[shopIds]' => '[associatedShopIds]',
121120
];
122121

tests/Integration/ApiPlatform/ContactEndpointTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ public function testPartialUpdateContact(int $contactId): int
131131
$updatedContact = $this->partialUpdateItem('/contacts/' . $contactId, $patchData, ['contact_write']);
132132
$this->assertSame($patchData['names'], $updatedContact['names']);
133133
$this->assertSame($patchData['email'], $updatedContact['email']);
134-
$this->assertSame((bool) $patchData['messagesSavingEnabled'], (bool) $updatedContact['messagesSavingEnabled']);
134+
135+
// We check that when we GET the item it is updated as expected
136+
$contact = $this->getItem('/contacts/' . $contactId, ['contact_read']);
137+
$this->assertSame($patchData['names'], $contact['names']);
138+
$this->assertSame($patchData['email'], $contact['email']);
139+
$this->assertArrayHasKey('messagesSavingEnabled', $contact);
140+
$this->assertSame((bool) $patchData['messagesSavingEnabled'], (bool) $contact['messagesSavingEnabled']);
135141

136142
return $contactId;
137143
}

0 commit comments

Comments
 (0)