Skip to content

Commit 5c2e3e3

Browse files
authored
Merge pull request PrestaShop#46 from jolelievre/api-doc
Modifications for API auto doc improvement
2 parents 0866e13 + 0d1715e commit 5c2e3e3

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
lines changed

src/ApiPlatform/Resources/ApiClient/ApiClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class ApiClient
9191

9292
public ?string $externalIssuer;
9393

94-
#[Assert\NotBlank(groups: ['Create'])]
94+
#[Assert\NotNull(groups: ['Create'])]
9595
public bool $enabled;
9696

9797
#[Assert\NotBlank(groups: ['Create'])]

src/ApiPlatform/Resources/Module/UploadModule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
'module_write',
4848
],
4949
CQRSCommandMapping: [
50-
'[archive][pathName]' => '[source]',
50+
'[archive].pathName' => '[source]',
5151
],
5252
),
5353
],

src/ApiPlatform/Resources/FoundProduct.php renamed to src/ApiPlatform/Resources/Product/FoundProduct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
declare(strict_types=1);
2222

23-
namespace PrestaShop\Module\APIResources\ApiPlatform\Resources;
23+
namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\Product;
2424

2525
use ApiPlatform\Metadata\ApiProperty;
2626
use ApiPlatform\Metadata\ApiResource;

src/ApiPlatform/Resources/Product/NewProductImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
CQRSQueryMapping: NewProductImage::QUERY_MAPPING,
4444
CQRSCommandMapping: [
4545
'[_context][shopConstraint]' => '[shopConstraint]',
46-
'[image][pathName]' => '[pathName]',
46+
'[image].pathName' => '[pathName]',
4747
],
4848
),
4949
],

src/ApiPlatform/Resources/Product/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Product
102102
#[LocalizedValue]
103103
public array $descriptions;
104104

105-
#[ApiProperty(openapiContext: ['type' => 'array', 'items' => ['type' => 'integer']])]
105+
#[ApiProperty(openapiContext: ['type' => 'array', 'items' => ['type' => 'integer'], 'example' => [1, 3]])]
106106
public array $shopIds;
107107

108108
public const QUERY_MAPPING = [

src/ApiPlatform/Resources/Product/ProductImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
CQRSQueryMapping: ProductImage::QUERY_MAPPING,
5959
CQRSCommandMapping: [
6060
'[_context][shopConstraint]' => '[shopConstraint]',
61-
'[image][pathName]' => '[filePath]',
61+
'[image].pathName' => '[filePath]',
6262
'[legends]' => '[localizedLegends]',
6363
'[cover]' => '[isCover]',
6464
]

tests/Integration/ApiPlatform/ApiClientEndpointTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public function testAddApiClient(): int
7171
'clientId' => 'client_id_test',
7272
'clientName' => 'Client name test',
7373
'description' => 'Client description test',
74-
'enabled' => true,
74+
// Check that false can be used (previously bug because of a NotBlank constraint)
75+
'enabled' => false,
7576
'lifetime' => 3600,
7677
'scopes' => [
7778
'api_client_read',
@@ -121,7 +122,7 @@ public function testGetApiClient(int $apiClientId): int
121122
'clientName' => 'Client name test',
122123
'description' => 'Client description test',
123124
'externalIssuer' => null,
124-
'enabled' => true,
125+
'enabled' => false,
125126
'lifetime' => 3600,
126127
'scopes' => [
127128
'api_client_read',
@@ -152,7 +153,7 @@ public function testUpdateApiClient(int $apiClientId): int
152153
'clientId' => 'client_id_test_updated',
153154
'clientName' => 'Client name test updated',
154155
'description' => 'Client description test updated',
155-
'enabled' => false,
156+
'enabled' => true,
156157
'lifetime' => 1800,
157158
'scopes' => [
158159
'api_client_write',
@@ -172,7 +173,7 @@ public function testUpdateApiClient(int $apiClientId): int
172173
'clientName' => 'Client name test updated',
173174
'description' => 'Client description test updated',
174175
'externalIssuer' => null,
175-
'enabled' => false,
176+
'enabled' => true,
176177
'lifetime' => 1800,
177178
'scopes' => [
178179
'api_client_write',
@@ -203,7 +204,7 @@ public function testUpdateApiClient(int $apiClientId): int
203204
'clientName' => 'Client name test updated',
204205
'description' => 'Client description test partially updated',
205206
'externalIssuer' => null,
206-
'enabled' => false,
207+
'enabled' => true,
207208
'lifetime' => 900,
208209
'scopes' => [
209210
'api_client_write',
@@ -240,7 +241,7 @@ public function testGetUpdatedApiClient(int $apiClientId): int
240241
'clientName' => 'Client name test updated',
241242
'description' => 'Client description test partially updated',
242243
'externalIssuer' => null,
243-
'enabled' => false,
244+
'enabled' => true,
244245
'lifetime' => 900,
245246
'scopes' => [
246247
'api_client_write',
@@ -274,7 +275,7 @@ public function testListApiClients(int $apiClientId): int
274275
'clientName' => 'Client name test updated',
275276
'description' => 'Client description test partially updated',
276277
'externalIssuer' => null,
277-
'enabled' => false,
278+
'enabled' => true,
278279
'lifetime' => 900,
279280
],
280281
$apiClients['items'][1],
@@ -368,7 +369,7 @@ public function testCreateInvalidApiClient(): void
368369
],
369370
[
370371
'propertyPath' => 'enabled',
371-
'message' => 'This value should not be blank.',
372+
'message' => 'This value should not be null.',
372373
],
373374
[
374375
'propertyPath' => 'description',

0 commit comments

Comments
 (0)