Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ which also has more detailed installation instructions in the README.

## API Documentation

Visit `/docs` endpoint to access the full interactive documentation for `phpList/rest-api`.
Visit `https://phplist.github.io/restapi-docs/` endpoint to access the full interactive documentation for `phpList/rest-api`.

Look at the **"API Documentation with Swagger"** section in the [contribution guide](.github/CONTRIBUTING.md) for more information on API documenation.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"require": {
"php": "^8.1",
"phplist/core": "dev-main",
"phplist/core": "dev-dev",
"friendsofsymfony/rest-bundle": "*",
"symfony/test-pack": "^1.0",
"symfony/process": "^6.4",
Expand Down
5 changes: 5 additions & 0 deletions config/services/validators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ services:
autowire: true
autoconfigure: true
tags: [ 'validator.constraint_validator' ]

PhpList\Core\Domain\Identity\Validator\AttributeTypeValidator:
autowire: true
autoconfigure: true

15 changes: 7 additions & 8 deletions src/Identity/Controller/AdminAttributeDefinitionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
use PhpList\RestBundle\Common\Controller\BaseController;
use PhpList\RestBundle\Common\Service\Provider\PaginatedDataProvider;
use PhpList\RestBundle\Common\Validator\RequestValidator;
use PhpList\RestBundle\Identity\Request\CreateAttributeDefinitionRequest;
use PhpList\RestBundle\Identity\Request\UpdateAttributeDefinitionRequest;
use PhpList\RestBundle\Identity\Request\AdminAttributeDefinitionRequest;
use PhpList\RestBundle\Identity\Serializer\AdminAttributeDefinitionNormalizer;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand Down Expand Up @@ -51,7 +50,7 @@ public function __construct(
requestBody: new OA\RequestBody(
description: 'Pass parameters to create admin attribute.',
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/CreateAdminAttributeDefinitionRequest')
content: new OA\JsonContent(ref: '#/components/schemas/AdminAttributeDefinitionRequest')
),
tags: ['admin-attributes'],
parameters: [
Expand Down Expand Up @@ -87,8 +86,8 @@ public function create(Request $request): JsonResponse
{
$this->requireAuthentication($request);

/** @var CreateAttributeDefinitionRequest $definitionRequest */
$definitionRequest = $this->validator->validate($request, CreateAttributeDefinitionRequest::class);
/** @var AdminAttributeDefinitionRequest $definitionRequest */
$definitionRequest = $this->validator->validate($request, AdminAttributeDefinitionRequest::class);

$attributeDefinition = $this->definitionManager->create($definitionRequest->getDto());
$this->entityManager->flush();
Expand All @@ -107,7 +106,7 @@ public function create(Request $request): JsonResponse
requestBody: new OA\RequestBody(
description: 'Pass parameters to update admin attribute.',
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/CreateAdminAttributeDefinitionRequest')
content: new OA\JsonContent(ref: '#/components/schemas/AdminAttributeDefinitionRequest')
),
tags: ['admin-attributes'],
parameters: [
Expand Down Expand Up @@ -153,8 +152,8 @@ public function update(
throw $this->createNotFoundException('Attribute definition not found.');
}

/** @var UpdateAttributeDefinitionRequest $definitionRequest */
$definitionRequest = $this->validator->validate($request, UpdateAttributeDefinitionRequest::class);
/** @var AdminAttributeDefinitionRequest $definitionRequest */
$definitionRequest = $this->validator->validate($request, AdminAttributeDefinitionRequest::class);

$attributeDefinition = $this->definitionManager->update(
attributeDefinition: $attributeDefinition,
Expand Down
15 changes: 12 additions & 3 deletions src/Identity/OpenApi/SwaggerSchemasRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PhpList\RestBundle\Identity\OpenApi;

use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Common\Model\AttributeTypeEnum;

#[OA\Schema(
schema: 'CreateAdministratorRequest',
Expand Down Expand Up @@ -96,15 +97,23 @@
type: 'object'
)]
#[OA\Schema(
schema: 'CreateAdminAttributeDefinitionRequest',
schema: 'AdminAttributeDefinitionRequest',
required: ['name'],
properties: [
new OA\Property(property: 'name', type: 'string', format: 'string', example: 'Country'),
new OA\Property(property: 'type', type: 'string', example: 'checkbox'),
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),
new OA\Property(property: 'table_name', type: 'string', example: 'list_attributes'),
],
type: 'object'
)]
Expand Down
3 changes: 1 addition & 2 deletions src/Identity/OpenApi/SwaggerSchemasResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
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: 'select'),
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),
new OA\Property(property: 'table_name', type: 'string', example: 'ukcounties'),
],
type: 'object'
)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PhpList\RestBundle\Common\Request\RequestInterface;
use Symfony\Component\Validator\Constraints as Assert;

class CreateAttributeDefinitionRequest implements RequestInterface
class AdminAttributeDefinitionRequest implements RequestInterface
{
#[Assert\NotBlank]
public string $name;
Expand All @@ -17,7 +17,6 @@ class CreateAttributeDefinitionRequest implements RequestInterface
public ?int $order = null;
public ?string $defaultValue = null;
public bool $required = false;
public ?string $tableName = null;

public function getDto(): AdminAttributeDefinitionDto
{
Expand All @@ -27,7 +26,6 @@ public function getDto(): AdminAttributeDefinitionDto
listOrder: $this->order,
defaultValue: $this->defaultValue,
required: $this->required,
tableName: $this->tableName,
);
}
}
33 changes: 0 additions & 33 deletions src/Identity/Request/UpdateAttributeDefinitionRequest.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
use PhpList\RestBundle\Common\Controller\BaseController;
use PhpList\RestBundle\Common\Service\Provider\PaginatedDataProvider;
use PhpList\RestBundle\Common\Validator\RequestValidator;
use PhpList\RestBundle\Subscription\Request\CreateAttributeDefinitionRequest;
use PhpList\RestBundle\Subscription\Request\UpdateAttributeDefinitionRequest;
use PhpList\RestBundle\Subscription\Request\SubscriberAttributeDefinitionRequest;
use PhpList\RestBundle\Subscription\Serializer\AttributeDefinitionNormalizer;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand Down Expand Up @@ -51,7 +50,7 @@ public function __construct(
requestBody: new OA\RequestBody(
description: 'Pass parameters to create subscriber attribute.',
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/CreateSubscriberAttributeDefinitionRequest')
content: new OA\JsonContent(ref: '#/components/schemas/SubscriberAttributeDefinitionRequest')
),
tags: ['subscriber-attributes'],
parameters: [
Expand Down Expand Up @@ -85,8 +84,8 @@ public function create(Request $request): JsonResponse
{
$this->requireAuthentication($request);

/** @var CreateAttributeDefinitionRequest $definitionRequest */
$definitionRequest = $this->validator->validate($request, CreateAttributeDefinitionRequest::class);
/** @var SubscriberAttributeDefinitionRequest $definitionRequest */
$definitionRequest = $this->validator->validate($request, SubscriberAttributeDefinitionRequest::class);

$attributeDefinition = $this->definitionManager->create($definitionRequest->getDto());
$this->entityManager->flush();
Expand All @@ -104,7 +103,7 @@ public function create(Request $request): JsonResponse
requestBody: new OA\RequestBody(
description: 'Pass parameters to update subscriber attribute.',
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/CreateSubscriberAttributeDefinitionRequest')
content: new OA\JsonContent(ref: '#/components/schemas/SubscriberAttributeDefinitionRequest')
),
tags: ['subscriber-attributes'],
parameters: [
Expand Down Expand Up @@ -150,8 +149,8 @@ public function update(
throw $this->createNotFoundException('Attribute definition not found.');
}

/** @var UpdateAttributeDefinitionRequest $definitionRequest */
$definitionRequest = $this->validator->validate($request, UpdateAttributeDefinitionRequest::class);
/** @var SubscriberAttributeDefinitionRequest $definitionRequest */
$definitionRequest = $this->validator->validate($request, SubscriberAttributeDefinitionRequest::class);

$attributeDefinition = $this->definitionManager->update(
attributeDefinition: $attributeDefinition,
Expand Down
107 changes: 0 additions & 107 deletions src/Subscription/OpenApi/SwaggerSchemasRequest.php

This file was deleted.

15 changes: 15 additions & 0 deletions src/Subscription/OpenApi/SwaggerSchemasResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,24 @@
new OA\Property(property: 'default_value', type: 'string', example: 'United States'),
new OA\Property(property: 'required', type: 'boolean', example: true),
new OA\Property(property: 'table_name', type: 'string', example: 'list_attributes'),
new OA\Property(
property: 'options',
type: 'array',
items: new OA\Items(ref: '#/components/schemas/DynamicListAttrOption'),
nullable: true,
),
],
type: 'object'
)]
#[OA\Schema(
schema: 'DynamicListAttrOption',
properties: [
new OA\Property(property: 'id', type: 'integer', example: 1, nullable: false),
new OA\Property(property: 'name', type: 'string', example: 'United States'),
new OA\Property(property: 'listorder', type: 'integer', example: 1, nullable: false),
],
type: 'object',
)]
#[OA\Schema(
schema: 'SubscriberAttributeValue',
properties: [
Expand Down
Loading
Loading