Skip to content

Commit 3f084aa

Browse files
TatevikGrtatevikg1
andauthored
Refactor/subscriber attribute routes (#162)
Refactor Subscriber attribute API reorganized to RESTful paths under /subscribers/{subscriberId}/attributes/{definitionId}. Documentation Large refresh of OpenAPI/Swagger schemas: many request/response schemas added, updated or removed across identity, messaging, statistics and subscription. Bug Fixes Normalized output fixes (corrected summary key, renamed super_admin → super_user, removed obsolete fields). Tests Updated integration and unit tests to match endpoint and normalization changes. Chores Minor PR template and repository metadata tweaks; new config toggle for docstring coverage (disabled). Thanks for contributing to phpList! * Fix tests * Update: coderabbit configs --------- Co-authored-by: Tatevik <tatevikg1@gmail.com>
1 parent 3c41f7e commit 3f084aa

File tree

43 files changed

+684
-731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+684
-731
lines changed

.coderabbit.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ reviews:
1414
base_branches:
1515
- ".*"
1616
drafts: false
17+
18+
checks:
19+
docstring_coverage:
20+
enabled: false

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
"@coderabbitai summary"
1+
@coderabbitai summary
22

33
Thanks for contributing to phpList!

src/Identity/OpenApi/SwaggerSchemasRequest.php

Lines changed: 0 additions & 122 deletions
This file was deleted.

src/Identity/OpenApi/SwaggerSchemasResponse.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/Identity/Request/AdminAttributeDefinitionRequest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace PhpList\RestBundle\Identity\Request;
66

7+
use OpenApi\Attributes as OA;
8+
use PhpList\Core\Domain\Common\Model\AttributeTypeEnum;
79
use PhpList\Core\Domain\Identity\Model\Dto\AdminAttributeDefinitionDto;
810
use PhpList\Core\Domain\Subscription\Validator\AttributeTypeValidator;
911
use PhpList\RestBundle\Common\Request\RequestInterface;
@@ -12,6 +14,27 @@
1214
use Symfony\Component\Validator\Context\ExecutionContextInterface;
1315
use Symfony\Component\Validator\Exception\ValidatorException;
1416

17+
#[OA\Schema(
18+
schema: 'AdminAttributeDefinitionRequest',
19+
required: ['name'],
20+
properties: [
21+
new OA\Property(property: 'name', type: 'string', format: 'string', example: 'Country'),
22+
new OA\Property(
23+
property: 'type',
24+
type: 'string',
25+
enum: [
26+
AttributeTypeEnum::TextLine,
27+
AttributeTypeEnum::Hidden,
28+
],
29+
example: 'hidden',
30+
nullable: true
31+
),
32+
new OA\Property(property: 'order', type: 'number', example: 12),
33+
new OA\Property(property: 'default_value', type: 'string', example: 'United States'),
34+
new OA\Property(property: 'required', type: 'boolean', example: true),
35+
],
36+
type: 'object'
37+
)]
1538
#[Assert\Callback('validateType')]
1639
class AdminAttributeDefinitionRequest implements RequestInterface
1740
{

src/Identity/Request/CreateAdministratorRequest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,59 @@
44

55
namespace PhpList\RestBundle\Identity\Request;
66

7+
use OpenApi\Attributes as OA;
78
use PhpList\Core\Domain\Identity\Model\Administrator;
89
use PhpList\Core\Domain\Identity\Model\Dto\CreateAdministratorDto;
910
use PhpList\RestBundle\Common\Request\RequestInterface;
1011
use PhpList\RestBundle\Identity\Validator\Constraint\UniqueEmail;
1112
use PhpList\RestBundle\Identity\Validator\Constraint\UniqueLoginName;
1213
use Symfony\Component\Validator\Constraints as Assert;
1314

15+
#[OA\Schema(
16+
schema: 'CreateAdministratorRequest',
17+
required: ['login_name', 'password', 'email', 'super_user'],
18+
properties: [
19+
new OA\Property(
20+
property: 'login_name',
21+
type: 'string',
22+
maxLength: 255,
23+
minLength: 3,
24+
example: 'admin'
25+
),
26+
new OA\Property(
27+
property: 'password',
28+
type: 'string',
29+
format: 'password',
30+
maxLength: 255,
31+
minLength: 6,
32+
example: 'StrongP@ssw0rd'
33+
),
34+
new OA\Property(
35+
property: 'email',
36+
type: 'string',
37+
format: 'email',
38+
example: 'admin@example.com'
39+
),
40+
new OA\Property(
41+
property: 'super_user',
42+
type: 'boolean',
43+
example: false
44+
),
45+
new OA\Property(
46+
property: 'privileges',
47+
description: 'Array of privileges where keys are privilege names and values are booleans',
48+
properties: [
49+
new OA\Property(property: 'subscribers', type: 'boolean', example: true),
50+
new OA\Property(property: 'campaigns', type: 'boolean', example: false),
51+
new OA\Property(property: 'statistics', type: 'boolean', example: true),
52+
new OA\Property(property: 'settings', type: 'boolean', example: false),
53+
],
54+
type: 'object',
55+
example: ['subscribers' => true, 'campaigns' => false, 'statistics' => true, 'settings' => false]
56+
),
57+
],
58+
type: 'object'
59+
)]
1460
class CreateAdministratorRequest implements RequestInterface
1561
{
1662
#[Assert\NotBlank]

src/Identity/Request/UpdateAdministratorRequest.php

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,58 @@
44

55
namespace PhpList\RestBundle\Identity\Request;
66

7+
use OpenApi\Attributes as OA;
78
use PhpList\Core\Domain\Identity\Model\Administrator;
89
use PhpList\Core\Domain\Identity\Model\Dto\UpdateAdministratorDto;
9-
use PhpList\Core\Domain\Identity\Model\PrivilegeFlag;
1010
use PhpList\RestBundle\Common\Request\RequestInterface;
1111
use PhpList\RestBundle\Identity\Validator\Constraint\UniqueEmail;
1212
use PhpList\RestBundle\Identity\Validator\Constraint\UniqueLoginName;
1313
use Symfony\Component\Validator\Constraints as Assert;
1414

15+
#[OA\Schema(
16+
schema: 'UpdateAdministratorRequest',
17+
properties: [
18+
new OA\Property(
19+
property: 'login_name',
20+
type: 'string',
21+
maxLength: 255,
22+
minLength: 3,
23+
example: 'admin'
24+
),
25+
new OA\Property(
26+
property: 'password',
27+
type: 'string',
28+
format: 'password',
29+
maxLength: 255,
30+
minLength: 6,
31+
example: 'StrongP@ssw0rd'
32+
),
33+
new OA\Property(
34+
property: 'email',
35+
type: 'string',
36+
format: 'email',
37+
example: 'admin@example.com'
38+
),
39+
new OA\Property(
40+
property: 'super_user',
41+
type: 'boolean',
42+
example: false
43+
),
44+
new OA\Property(
45+
property: 'privileges',
46+
description: 'Array of privileges where keys are privilege names and values are booleans',
47+
properties: [
48+
new OA\Property(property: 'subscribers', type: 'boolean', example: true),
49+
new OA\Property(property: 'campaigns', type: 'boolean', example: false),
50+
new OA\Property(property: 'statistics', type: 'boolean', example: true),
51+
new OA\Property(property: 'settings', type: 'boolean', example: false),
52+
],
53+
type: 'object',
54+
example: ['subscribers' => true, 'campaigns' => false, 'statistics' => true, 'settings' => false]
55+
),
56+
],
57+
type: 'object'
58+
)]
1559
class UpdateAdministratorRequest implements RequestInterface
1660
{
1761
public int $administratorId;
@@ -28,7 +72,7 @@ class UpdateAdministratorRequest implements RequestInterface
2872
public ?string $email = null;
2973

3074
#[Assert\Type('bool')]
31-
public ?bool $superAdmin = null;
75+
public ?bool $superUser = null;
3276

3377
/**
3478
* Array of privileges where keys are privilege names (from PrivilegeFlag enum) and values are booleans.
@@ -49,7 +93,7 @@ public function getDto(): UpdateAdministratorDto
4993
loginName: $this->loginName,
5094
password: $this->password,
5195
email: $this->email,
52-
superAdmin: $this->superAdmin,
96+
superAdmin: $this->superUser,
5397
privileges: $this->privileges
5498
);
5599
}

src/Identity/Serializer/AdminAttributeDefinitionNormalizer.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@
44

55
namespace PhpList\RestBundle\Identity\Serializer;
66

7+
use OpenApi\Attributes as OA;
78
use PhpList\Core\Domain\Identity\Model\AdminAttributeDefinition;
89
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
910

11+
#[OA\Schema(
12+
schema: 'AdminAttributeDefinition',
13+
properties: [
14+
new OA\Property(property: 'id', type: 'integer', example: 1),
15+
new OA\Property(property: 'name', type: 'string', example: 'Country'),
16+
new OA\Property(property: 'type', type: 'string', example: 'hidden'),
17+
new OA\Property(property: 'list_order', type: 'integer', example: 12),
18+
new OA\Property(property: 'default_value', type: 'string', example: 'United States'),
19+
new OA\Property(property: 'required', type: 'boolean', example: true),
20+
],
21+
type: 'object'
22+
)]
1023
class AdminAttributeDefinitionNormalizer implements NormalizerInterface
1124
{
1225
/**
@@ -25,7 +38,6 @@ public function normalize($object, string $format = null, array $context = []):
2538
'list_order' => $object->getListOrder(),
2639
'default_value' => $object->getDefaultValue(),
2740
'required' => $object->isRequired(),
28-
'table_name' => $object->getTableName(),
2941
];
3042
}
3143

0 commit comments

Comments
 (0)