Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications for API auto doc improvement #46

Merged
merged 4 commits into from
Jan 23, 2025
Merged
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
2 changes: 1 addition & 1 deletion src/ApiPlatform/Resources/ApiClient/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ApiClient

public ?string $externalIssuer;

#[Assert\NotBlank(groups: ['Create'])]
#[Assert\NotNull(groups: ['Create'])]
public bool $enabled;

#[Assert\NotBlank(groups: ['Create'])]
Expand Down
2 changes: 1 addition & 1 deletion src/ApiPlatform/Resources/Module/UploadModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
'module_write',
],
CQRSCommandMapping: [
'[archive][pathName]' => '[source]',
'[archive].pathName' => '[source]',
],
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

declare(strict_types=1);

namespace PrestaShop\Module\APIResources\ApiPlatform\Resources;
namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\Product;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
Expand Down
2 changes: 1 addition & 1 deletion src/ApiPlatform/Resources/Product/NewProductImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
CQRSQueryMapping: NewProductImage::QUERY_MAPPING,
CQRSCommandMapping: [
'[_context][shopConstraint]' => '[shopConstraint]',
'[image][pathName]' => '[pathName]',
'[image].pathName' => '[pathName]',
],
),
],
Expand Down
2 changes: 1 addition & 1 deletion src/ApiPlatform/Resources/Product/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Product
#[LocalizedValue]
public array $descriptions;

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

public const QUERY_MAPPING = [
Expand Down
2 changes: 1 addition & 1 deletion src/ApiPlatform/Resources/Product/ProductImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
CQRSQueryMapping: ProductImage::QUERY_MAPPING,
CQRSCommandMapping: [
'[_context][shopConstraint]' => '[shopConstraint]',
'[image][pathName]' => '[filePath]',
'[image].pathName' => '[filePath]',
'[legends]' => '[localizedLegends]',
'[cover]' => '[isCover]',
]
Expand Down
17 changes: 9 additions & 8 deletions tests/Integration/ApiPlatform/ApiClientEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public function testAddApiClient(): int
'clientId' => 'client_id_test',
'clientName' => 'Client name test',
'description' => 'Client description test',
'enabled' => true,
// Check that false can be used (previously bug because of a NotBlank constraint)
'enabled' => false,
'lifetime' => 3600,
'scopes' => [
'api_client_read',
Expand Down Expand Up @@ -121,7 +122,7 @@ public function testGetApiClient(int $apiClientId): int
'clientName' => 'Client name test',
'description' => 'Client description test',
'externalIssuer' => null,
'enabled' => true,
'enabled' => false,
'lifetime' => 3600,
'scopes' => [
'api_client_read',
Expand Down Expand Up @@ -152,7 +153,7 @@ public function testUpdateApiClient(int $apiClientId): int
'clientId' => 'client_id_test_updated',
'clientName' => 'Client name test updated',
'description' => 'Client description test updated',
'enabled' => false,
'enabled' => true,
'lifetime' => 1800,
'scopes' => [
'api_client_write',
Expand All @@ -172,7 +173,7 @@ public function testUpdateApiClient(int $apiClientId): int
'clientName' => 'Client name test updated',
'description' => 'Client description test updated',
'externalIssuer' => null,
'enabled' => false,
'enabled' => true,
'lifetime' => 1800,
'scopes' => [
'api_client_write',
Expand Down Expand Up @@ -203,7 +204,7 @@ public function testUpdateApiClient(int $apiClientId): int
'clientName' => 'Client name test updated',
'description' => 'Client description test partially updated',
'externalIssuer' => null,
'enabled' => false,
'enabled' => true,
'lifetime' => 900,
'scopes' => [
'api_client_write',
Expand Down Expand Up @@ -240,7 +241,7 @@ public function testGetUpdatedApiClient(int $apiClientId): int
'clientName' => 'Client name test updated',
'description' => 'Client description test partially updated',
'externalIssuer' => null,
'enabled' => false,
'enabled' => true,
'lifetime' => 900,
'scopes' => [
'api_client_write',
Expand Down Expand Up @@ -274,7 +275,7 @@ public function testListApiClients(int $apiClientId): int
'clientName' => 'Client name test updated',
'description' => 'Client description test partially updated',
'externalIssuer' => null,
'enabled' => false,
'enabled' => true,
'lifetime' => 900,
],
$apiClients['items'][1],
Expand Down Expand Up @@ -368,7 +369,7 @@ public function testCreateInvalidApiClient(): void
],
[
'propertyPath' => 'enabled',
'message' => 'This value should not be blank.',
'message' => 'This value should not be null.',
],
[
'propertyPath' => 'description',
Expand Down
Loading