Skip to content

Commit 1f9f2cf

Browse files
committed
chore(api): fixed swagger doc for attributes
1 parent 66f06b2 commit 1f9f2cf

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
@@ -93,6 +93,7 @@ class Attribute
9393
public int $attributeGroupId;
9494

9595
#[LocalizedValue]
96+
#[Assert\NotBlank(groups: ['Create'])]
9697
#[DefaultLanguage(groups: ['Create'], fieldName: 'names')]
9798
#[DefaultLanguage(groups: ['Update'], fieldName: 'names', allowNull: true)]
9899
#[Assert\All(constraints: [
@@ -108,16 +109,14 @@ class Attribute
108109
#[Assert\NotBlank(allowNull: true)]
109110
public array $shopIds;
110111

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

119118
public const CREATE_COMMAND_MAPPING = [
120-
'[names]' => '[localizedValue]',
119+
'[names]' => '[localizedNames]',
121120
'[shopIds]' => '[associatedShopIds]',
122121
];
123122

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)