Skip to content

Commit 3c1fac6

Browse files
committed
ISSUE-345: 422 in schema
1 parent dc3ff0b commit 3c1fac6

File tree

5 files changed

+30
-21
lines changed

5 files changed

+30
-21
lines changed

Diff for: composer.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@
2929
"forum": "https://discuss.phplist.org/",
3030
"source": "https://github.com/phpList/rest-api"
3131
},
32+
"repositories": [
33+
{
34+
"type": "vcs",
35+
"url": "https://github.com/phpList/core"
36+
}
37+
],
3238
"require": {
3339
"php": "^8.1",
34-
"phplist/core": "v5.0.0-alpha4",
40+
"phplist/core": "dev-ISSUE-345",
3541
"friendsofsymfony/rest-bundle": "*",
3642
"symfony/test-pack": "^1.0",
3743
"symfony/process": "^6.4",

Diff for: src/Controller/ListController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(
4747
$this->serializer = $serializer;
4848
}
4949

50-
#[Route('/', name: 'get_lists', methods: ['GET'])]
50+
#[Route('', name: 'get_lists', methods: ['GET'])]
5151
#[OA\Get(
5252
path: '/lists',
5353
description: 'Returns a JSON list of all subscriber lists.',

Diff for: src/Controller/SubscriberController.php

+7-10
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,8 @@ public function __construct(Authentication $authentication, SubscriberManager $s
9090
new OA\Response(
9191
response: 422,
9292
description: 'Failure',
93-
content: new OA\JsonContent(
94-
properties: [
95-
new OA\Property(
96-
property: 'message',
97-
type: 'string',
98-
example: 'Some fields invalid: email, confirmed, html_email'
99-
)
100-
]
101-
)
102-
)
93+
content: new OA\JsonContent(ref: '#/components/schemas/ValidationErrorResponse')
94+
),
10395
]
10496
)]
10597
public function createSubscriber(
@@ -170,6 +162,11 @@ public function createSubscriber(
170162
description: 'Failure',
171163
content: new OA\JsonContent(ref: '#/components/schemas/UnauthorizedResponse')
172164
),
165+
new OA\Response(
166+
response: 422,
167+
description: 'Failure',
168+
content: new OA\JsonContent(ref: '#/components/schemas/ValidationErrorResponse')
169+
),
173170
new OA\Response(
174171
response: 404,
175172
description: 'Not Found',

Diff for: src/Controller/Traits/AuthenticationTrait.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace PhpList\RestBundle\Controller\Traits;
@@ -9,26 +10,20 @@
910
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
1011

1112
/**
12-
* This traits provides functionality for authenticating the REST API client.
13+
* This trait provides functionality for authenticating the REST API client.
1314
*
1415
* Please note that this trait requires the class to set the authentication instance via DI.
1516
*
1617
* @author Oliver Klee <[email protected]>
18+
* @author Tatevik Grigoryan <[email protected]>
1719
*/
1820
trait AuthenticationTrait
1921
{
20-
/**
21-
* @var Authentication
22-
*/
23-
private $authentication = null;
22+
private ?Authentication $authentication = null;
2423

2524
/**
2625
* Checks for valid authentication in the given request and throws an exception if there is none.
2726
*
28-
* @param Request $request
29-
*
30-
* @return Administrator the authenticated administrator
31-
*
3227
* @throws AccessDeniedHttpException
3328
*/
3429
private function requireAuthentication(Request $request): Administrator

Diff for: src/OpenApi/SwaggerSchemas.php

+11
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@
5858
],
5959
type: 'object'
6060
)]
61+
#[OA\Schema(
62+
schema: 'ValidationErrorResponse',
63+
properties: [
64+
new OA\Property(
65+
property: 'message',
66+
type: 'string',
67+
example: 'Some fields invalid: email, confirmed, html_email'
68+
)
69+
],
70+
type: 'object'
71+
)]
6172
class SwaggerSchemas
6273
{
6374
}

0 commit comments

Comments
 (0)