Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"@coderabbitai summary"
@coderabbitai summary

Thanks for contributing to phpList!
122 changes: 0 additions & 122 deletions src/Identity/OpenApi/SwaggerSchemasRequest.php

This file was deleted.

48 changes: 0 additions & 48 deletions src/Identity/OpenApi/SwaggerSchemasResponse.php

This file was deleted.

23 changes: 23 additions & 0 deletions src/Identity/Request/AdminAttributeDefinitionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace PhpList\RestBundle\Identity\Request;

use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Common\Model\AttributeTypeEnum;
use PhpList\Core\Domain\Identity\Model\Dto\AdminAttributeDefinitionDto;
use PhpList\Core\Domain\Subscription\Validator\AttributeTypeValidator;
use PhpList\RestBundle\Common\Request\RequestInterface;
Expand All @@ -12,6 +14,27 @@
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Exception\ValidatorException;

#[OA\Schema(
schema: 'AdminAttributeDefinitionRequest',
required: ['name'],
properties: [
new OA\Property(property: 'name', type: 'string', format: 'string', example: 'Country'),
new OA\Property(
property: 'type',
type: 'string',
enum: [
AttributeTypeEnum::TextLine,
AttributeTypeEnum::Hidden,
],
example: 'hidden',
nullable: true
),
new OA\Property(property: 'order', type: 'number', example: 12),
new OA\Property(property: 'default_value', type: 'string', example: 'United States'),
new OA\Property(property: 'required', type: 'boolean', example: true),
],
type: 'object'
)]
#[Assert\Callback('validateType')]
class AdminAttributeDefinitionRequest implements RequestInterface
{
Expand Down
46 changes: 46 additions & 0 deletions src/Identity/Request/CreateAdministratorRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,59 @@

namespace PhpList\RestBundle\Identity\Request;

use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\Administrator;
use PhpList\Core\Domain\Identity\Model\Dto\CreateAdministratorDto;
use PhpList\RestBundle\Common\Request\RequestInterface;
use PhpList\RestBundle\Identity\Validator\Constraint\UniqueEmail;
use PhpList\RestBundle\Identity\Validator\Constraint\UniqueLoginName;
use Symfony\Component\Validator\Constraints as Assert;

#[OA\Schema(
schema: 'CreateAdministratorRequest',
required: ['login_name', 'password', 'email', 'super_user'],
properties: [
new OA\Property(
property: 'login_name',
type: 'string',
maxLength: 255,
minLength: 3,
example: 'admin'
),
new OA\Property(
property: 'password',
type: 'string',
format: 'password',
maxLength: 255,
minLength: 6,
example: 'StrongP@ssw0rd'
),
new OA\Property(
property: 'email',
type: 'string',
format: 'email',
example: '[email protected]'
),
new OA\Property(
property: 'super_user',
type: 'boolean',
example: false
),
new OA\Property(
property: 'privileges',
description: 'Array of privileges where keys are privilege names and values are booleans',
properties: [
new OA\Property(property: 'subscribers', type: 'boolean', example: true),
new OA\Property(property: 'campaigns', type: 'boolean', example: false),
new OA\Property(property: 'statistics', type: 'boolean', example: true),
new OA\Property(property: 'settings', type: 'boolean', example: false),
],
type: 'object',
example: ['subscribers' => true, 'campaigns' => false, 'statistics' => true, 'settings' => false]
),
],
type: 'object'
)]
class CreateAdministratorRequest implements RequestInterface
{
#[Assert\NotBlank]
Expand Down
50 changes: 47 additions & 3 deletions src/Identity/Request/UpdateAdministratorRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,58 @@

namespace PhpList\RestBundle\Identity\Request;

use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\Administrator;
use PhpList\Core\Domain\Identity\Model\Dto\UpdateAdministratorDto;
use PhpList\Core\Domain\Identity\Model\PrivilegeFlag;
use PhpList\RestBundle\Common\Request\RequestInterface;
use PhpList\RestBundle\Identity\Validator\Constraint\UniqueEmail;
use PhpList\RestBundle\Identity\Validator\Constraint\UniqueLoginName;
use Symfony\Component\Validator\Constraints as Assert;

#[OA\Schema(
schema: 'UpdateAdministratorRequest',
properties: [
new OA\Property(
property: 'login_name',
type: 'string',
maxLength: 255,
minLength: 3,
example: 'admin'
),
new OA\Property(
property: 'password',
type: 'string',
format: 'password',
maxLength: 255,
minLength: 6,
example: 'StrongP@ssw0rd'
),
new OA\Property(
property: 'email',
type: 'string',
format: 'email',
example: '[email protected]'
),
new OA\Property(
property: 'super_user',
type: 'boolean',
example: false
),
new OA\Property(
property: 'privileges',
description: 'Array of privileges where keys are privilege names and values are booleans',
properties: [
new OA\Property(property: 'subscribers', type: 'boolean', example: true),
new OA\Property(property: 'campaigns', type: 'boolean', example: false),
new OA\Property(property: 'statistics', type: 'boolean', example: true),
new OA\Property(property: 'settings', type: 'boolean', example: false),
],
type: 'object',
example: ['subscribers' => true, 'campaigns' => false, 'statistics' => true, 'settings' => false]
),
],
type: 'object'
)]
class UpdateAdministratorRequest implements RequestInterface
{
public int $administratorId;
Expand All @@ -28,7 +72,7 @@ class UpdateAdministratorRequest implements RequestInterface
public ?string $email = null;

#[Assert\Type('bool')]
public ?bool $superAdmin = null;
public ?bool $superUser = null;

/**
* Array of privileges where keys are privilege names (from PrivilegeFlag enum) and values are booleans.
Expand All @@ -49,7 +93,7 @@ public function getDto(): UpdateAdministratorDto
loginName: $this->loginName,
password: $this->password,
email: $this->email,
superAdmin: $this->superAdmin,
superAdmin: $this->superUser,
privileges: $this->privileges
);
}
Expand Down
14 changes: 13 additions & 1 deletion src/Identity/Serializer/AdminAttributeDefinitionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@

namespace PhpList\RestBundle\Identity\Serializer;

use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\AdminAttributeDefinition;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

#[OA\Schema(
schema: 'AdminAttributeDefinition',
properties: [
new OA\Property(property: 'id', type: 'integer', example: 1),
new OA\Property(property: 'name', type: 'string', example: 'Country'),
new OA\Property(property: 'type', type: 'string', example: 'hidden'),
new OA\Property(property: 'list_order', type: 'integer', example: 12),
new OA\Property(property: 'default_value', type: 'string', example: 'United States'),
new OA\Property(property: 'required', type: 'boolean', example: true),
],
type: 'object'
)]
class AdminAttributeDefinitionNormalizer implements NormalizerInterface
{
/**
Expand All @@ -25,7 +38,6 @@ public function normalize($object, string $format = null, array $context = []):
'list_order' => $object->getListOrder(),
'default_value' => $object->getDefaultValue(),
'required' => $object->isRequired(),
'table_name' => $object->getTableName(),
];
}

Expand Down
Loading
Loading