Skip to content

Commit 6600cc9

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

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ApiPlatform/Resources/Attribute/Attribute.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ class Attribute
9292
public int $attributeGroupId;
9393

9494
#[LocalizedValue]
95+
#[ApiProperty(
96+
openapiContext: [
97+
'type' => 'object',
98+
'example' => ['en-US' => 'Value name', 'fr-FR' => 'Nom de la valeur'],
99+
'description' => 'Localized attribute names indexed by locale (e.g., en-US, fr-FR). Required for creation.',
100+
]
101+
)]
102+
#[Assert\NotBlank(groups: ['Create'])]
95103
#[DefaultLanguage(groups: ['Create'], fieldName: 'names')]
96104
#[DefaultLanguage(groups: ['Update'], fieldName: 'names', allowNull: true)]
97105
#[Assert\All(constraints: [
@@ -107,6 +115,7 @@ class Attribute
107115
#[Assert\NotBlank(allowNull: true)]
108116
public array $shopIds;
109117

118+
#[ApiProperty(writable: false)]
110119
public int $position;
111120

112121
public const QUERY_MAPPING = [
@@ -116,7 +125,7 @@ class Attribute
116125
];
117126

118127
public const CREATE_COMMAND_MAPPING = [
119-
'[names]' => '[localizedValue]',
128+
'[names]' => '[localizedNames]',
120129
'[shopIds]' => '[associatedShopIds]',
121130
];
122131

tests/Integration/ApiPlatform/ContactEndpointTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ 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->assertArrayHasKey('messagesSavingEnabled', $updatedContact);
134135
$this->assertSame((bool) $patchData['messagesSavingEnabled'], (bool) $updatedContact['messagesSavingEnabled']);
135136

136137
return $contactId;

0 commit comments

Comments
 (0)