Skip to content

Commit a3f907c

Browse files
Use named arguments for rest routes
1 parent c3efdb8 commit a3f907c

21 files changed

+137
-137
lines changed

webapp/src/Controller/API/AccessController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Symfony\Component\HttpFoundation\Request;
1313
use Symfony\Component\Security\Http\Attribute\IsGranted;
1414

15-
#[Rest\Route('/contests/{cid}/access')]
15+
#[Rest\Route(path: '/contests/{cid}/access')]
1616
#[OA\Tag(name: 'Access')]
1717
#[OA\Parameter(ref: '#/components/parameters/cid')]
1818
#[OA\Parameter(ref: '#/components/parameters/strict')]
@@ -31,7 +31,7 @@ class AccessController extends AbstractApiController
3131
* @return Access
3232
*/
3333
#[IsGranted('ROLE_API_READER')]
34-
#[Rest\Get('')]
34+
#[Rest\Get(path: '')]
3535
#[OA\Response(
3636
response: 200,
3737
description: 'Access information for the given contest',

webapp/src/Controller/API/AccountController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* @extends AbstractRestController<User, User>
1919
*/
20-
#[Rest\Route('/contests/{cid}')]
20+
#[Rest\Route(path: '/contests/{cid}')]
2121
#[OA\Tag(name: 'Accounts')]
2222
#[OA\Parameter(ref: '#/components/parameters/cid')]
2323
#[OA\Parameter(ref: '#/components/parameters/strict')]
@@ -38,7 +38,7 @@ class AccountController extends AbstractRestController
3838
* @throws NonUniqueResultException
3939
*/
4040
#[IsGranted(new Expression("is_granted('ROLE_ADMIN') or is_granted('ROLE_API_READER')"))]
41-
#[Rest\Get('/accounts')]
41+
#[Rest\Get(path: '/accounts')]
4242
#[OA\Response(
4343
response: 200,
4444
description: 'Returns all the accounts for this contest',
@@ -66,7 +66,7 @@ public function listAction(Request $request): Response
6666
* @throws NonUniqueResultException
6767
*/
6868
#[IsGranted(new Expression("is_granted('ROLE_ADMIN') or is_granted('ROLE_API_READER')"))]
69-
#[Rest\Get('/accounts/{id}')]
69+
#[Rest\Get(path: '/accounts/{id}')]
7070
#[OA\Response(
7171
response: 200,
7272
description: 'Returns the given account',
@@ -83,7 +83,7 @@ public function singleAction(Request $request, string $id): Response
8383
/**
8484
* Get information about the currently logged in account.
8585
*/
86-
#[Rest\Get('/account')]
86+
#[Rest\Get(path: '/account')]
8787
#[OA\Response(
8888
response: 200,
8989
description: 'Information about the logged in account',

webapp/src/Controller/API/AwardsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
2020
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2121

22-
#[Rest\Route('/contests/{cid}/awards')]
22+
#[Rest\Route(path: '/contests/{cid}/awards')]
2323
#[OA\Tag(name: 'Awards')]
2424
#[OA\Parameter(ref: '#/components/parameters/cid')]
2525
#[OA\Parameter(ref: '#/components/parameters/strict')]
@@ -46,7 +46,7 @@ public function __construct(
4646
*
4747
* @return Award[]
4848
*/
49-
#[Rest\Get('')]
49+
#[Rest\Get(path: '')]
5050
#[OA\Response(
5151
response: 200,
5252
description: 'Returns the current teams qualifying for each award',
@@ -66,7 +66,7 @@ public function listAction(Request $request): array
6666
*
6767
* @throws Exception
6868
*/
69-
#[Rest\Get('/{id}')]
69+
#[Rest\Get(path: '/{id}')]
7070
#[OA\Response(
7171
response: 200,
7272
description: 'Returns the award for this contest',

webapp/src/Controller/API/BalloonController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\Security\Http\Attribute\IsGranted;
1717

1818
#[IsGranted(new Expression("is_granted('ROLE_JURY') or is_granted('ROLE_API_READER') or is_granted('ROLE_BALLOON')"))]
19-
#[Rest\Route('/contests/{cid}/balloons')]
19+
#[Rest\Route(path: '/contests/{cid}/balloons')]
2020
#[OA\Tag(name: 'Balloons')]
2121
#[OA\Parameter(ref: '#/components/parameters/cid')]
2222
#[OA\Response(ref: '#/components/responses/NotFound', response: 404)]
@@ -31,7 +31,7 @@ class BalloonController extends AbstractApiController
3131
* @throws NonUniqueResultException
3232
* @return Balloon[]
3333
*/
34-
#[Rest\Get('')]
34+
#[Rest\Get(path: '')]
3535
#[OA\Response(
3636
response: 200,
3737
description: 'Returns the balloons for this contest.',
@@ -84,7 +84,7 @@ public function listAction(
8484
* Mark a specific balloon as done.
8585
*/
8686
#[IsGranted(new Expression("is_granted('ROLE_JURY') or is_granted('ROLE_BALLOON')"))]
87-
#[Rest\Post('/{balloonId<\d+>}/done')]
87+
#[Rest\Post(path: '/{balloonId<\d+>}/done')]
8888
#[OA\Response(
8989
response: 204,
9090
description: 'The balloon was now marked as done or already marked as such.'

webapp/src/Controller/API/ClarificationController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/**
2525
* @extends AbstractRestController<Clarification, Clarification>
2626
*/
27-
#[Rest\Route('/contests/{cid}/clarifications')]
27+
#[Rest\Route(path: '/contests/{cid}/clarifications')]
2828
#[OA\Tag(name: 'Clarifications')]
2929
#[OA\Parameter(ref: '#/components/parameters/cid')]
3030
#[OA\Parameter(ref: '#/components/parameters/strict')]
@@ -40,7 +40,7 @@ class ClarificationController extends AbstractRestController
4040
* Note that we restrict the returned clarifications in the query builder.
4141
* @throws NonUniqueResultException
4242
*/
43-
#[Rest\Get('')]
43+
#[Rest\Get(path: '')]
4444
#[OA\Response(
4545
response: 200,
4646
description: 'Returns all the clarifications for this contest',
@@ -69,7 +69,7 @@ public function listAction(Request $request): Response
6969
* team user gets general clarifications plus those sent from or to the team.
7070
* @throws NonUniqueResultException
7171
*/
72-
#[Rest\Get('/{id}')]
72+
#[Rest\Get(path: '/{id}')]
7373
#[OA\Response(
7474
response: 200,
7575
description: 'Returns the given clarification for this contest',
@@ -89,8 +89,8 @@ public function singleAction(Request $request, string $id): Response
8989
new Expression("is_granted('ROLE_TEAM') or is_granted('ROLE_API_WRITER')"),
9090
message: 'You need to have the Team Member role to add a clarification'
9191
)]
92-
#[Rest\Post('')]
93-
#[Rest\Put('/{id}')]
92+
#[Rest\Post(path: '')]
93+
#[Rest\Put(path: '/{id}')]
9494
#[OA\RequestBody(
9595
required: true,
9696
content: [

webapp/src/Controller/API/ContestController.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
/**
5151
* @extends AbstractRestController<Contest, Contest>
5252
*/
53-
#[Rest\Route('/contests')]
53+
#[Rest\Route(path: '/contests')]
5454
#[OA\Tag(name: 'Contests')]
5555
#[OA\Parameter(ref: '#/components/parameters/strict')]
5656
#[OA\Response(ref: '#/components/responses/InvalidResponse', response: 400)]
@@ -76,7 +76,7 @@ public function __construct(
7676
* @throws BadRequestHttpException
7777
*/
7878
#[IsGranted('ROLE_ADMIN')]
79-
#[Rest\Post('')]
79+
#[Rest\Post(path: '')]
8080
#[OA\RequestBody(
8181
required: true,
8282
content: new OA\MediaType(
@@ -126,7 +126,7 @@ public function addContestAction(Request $request): string
126126
* Get all the contests.
127127
* @throws NonUniqueResultException
128128
*/
129-
#[Rest\Get('')]
129+
#[Rest\Get(path: '')]
130130
#[OA\Response(
131131
response: 200,
132132
description: 'Returns all contests visible to the user (all contests for privileged users, active contests otherwise)',
@@ -151,7 +151,7 @@ public function listAction(Request $request): Response
151151
* Get the given contest.
152152
* @throws NonUniqueResultException
153153
*/
154-
#[Rest\Get('/{cid}')]
154+
#[Rest\Get(path: '/{cid}')]
155155
#[OA\Response(
156156
response: 200,
157157
description: 'Returns the given contest',
@@ -166,7 +166,7 @@ public function singleAction(Request $request, string $cid): Response
166166
/**
167167
* Get the banner for the given contest.
168168
*/
169-
#[Rest\Get('/{cid}/banner', name: 'contest_banner')]
169+
#[Rest\Get(path: '/{cid}/banner', name: 'contest_banner')]
170170
#[OA\Response(
171171
response: 200,
172172
description: 'Returns the given contest banner in PNG, JPG or SVG format',
@@ -202,7 +202,7 @@ public function bannerAction(Request $request, string $cid): Response
202202
* Delete the banner for the given contest.
203203
*/
204204
#[IsGranted('ROLE_ADMIN')]
205-
#[Rest\Delete('/{cid}/banner', name: 'delete_contest_banner')]
205+
#[Rest\Delete(path: '/{cid}/banner', name: 'delete_contest_banner')]
206206
#[OA\Response(response: 204, description: 'Deleting banner succeeded')]
207207
#[OA\Parameter(ref: '#/components/parameters/cid')]
208208
public function deleteBannerAction(Request $request, string $cid): Response
@@ -270,7 +270,7 @@ public function setBannerAction(Request $request, string $cid, ValidatorInterfac
270270
* Delete the problemset document for the given contest.
271271
*/
272272
#[IsGranted('ROLE_ADMIN')]
273-
#[Rest\Delete('/{cid}/problemset', name: 'delete_contest_problemset')]
273+
#[Rest\Delete(path: '/{cid}/problemset', name: 'delete_contest_problemset')]
274274
#[OA\Response(response: 204, description: 'Deleting problemset document succeeded')]
275275
#[OA\Parameter(ref: '#/components/parameters/cid')]
276276
public function deleteProblemsetAction(Request $request, string $cid): Response
@@ -342,7 +342,7 @@ public function setProblemsetAction(Request $request, string $cid, ValidatorInte
342342
/**
343343
* Get the problemset document for the given contest.
344344
*/
345-
#[Rest\Get('/{cid}/problemset', name: 'contest_problemset')]
345+
#[Rest\Get(path: '/{cid}/problemset', name: 'contest_problemset')]
346346
#[OA\Response(
347347
response: 200,
348348
description: 'Returns the given contest problemset document in PDF, HTML or TXT format',
@@ -386,7 +386,7 @@ public function problemsetAction(Request $request, string $cid): Response
386386
* @throws NonUniqueResultException
387387
*/
388388
#[IsGranted('ROLE_API_WRITER')]
389-
#[Rest\Patch('/{cid}')]
389+
#[Rest\Patch(path: '/{cid}')]
390390
#[OA\RequestBody(
391391
required: true,
392392
content: new OA\MediaType(
@@ -498,7 +498,7 @@ public function changeStartTimeAction(
498498
* Get the contest in YAML format.
499499
* @throws NonUniqueResultException
500500
*/
501-
#[Rest\Get('/{cid}/contest-yaml')]
501+
#[Rest\Get(path: '/{cid}/contest-yaml')]
502502
#[OA\Parameter(ref: '#/components/parameters/cid')]
503503
#[OA\Response(
504504
response: 200,
@@ -525,7 +525,7 @@ public function getContestYamlAction(Request $request, string $cid): StreamedRes
525525
* Get the current contest state
526526
* @throws NonUniqueResultException
527527
*/
528-
#[Rest\Get('/{cid}/state')]
528+
#[Rest\Get(path: '/{cid}/state')]
529529
#[OA\Parameter(ref: '#/components/parameters/cid')]
530530
#[OA\Response(
531531
response: 200,
@@ -548,7 +548,7 @@ public function getContestStateAction(Request $request, string $cid): ContestSta
548548
* @throws NonUniqueResultException
549549
*/
550550
#[IsGranted(new Expression("is_granted('ROLE_JURY') or is_granted('ROLE_API_READER')"))]
551-
#[Rest\Get('/{cid}/event-feed')]
551+
#[Rest\Get(path: '/{cid}/event-feed')]
552552
#[OA\Parameter(ref: '#/components/parameters/cid')]
553553
#[OA\Parameter(
554554
name: 'since_id',
@@ -914,7 +914,7 @@ public function getEventFeedAction(
914914
* @throws NonUniqueResultException
915915
*/
916916
#[IsGranted('ROLE_API_READER')]
917-
#[Rest\Get('/{cid}/status')]
917+
#[Rest\Get(path: '/{cid}/status')]
918918
#[OA\Parameter(ref: '#/components/parameters/cid')]
919919
#[OA\Response(
920920
response: 200,
@@ -926,7 +926,7 @@ public function getStatusAction(Request $request, string $cid): ContestStatus
926926
return $this->dj->getContestStats($this->getContestWithId($request, $cid));
927927
}
928928

929-
#[Rest\Get('/{cid}/samples.zip', name: 'samples_data_zip')]
929+
#[Rest\Get(path: '/{cid}/samples.zip', name: 'samples_data_zip')]
930930
#[OA\Response(
931931
response: 200,
932932
description: 'The problem samples, statement & attachments as a ZIP archive',

webapp/src/Controller/API/ExecutableController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1414
use Symfony\Component\Security\Http\Attribute\IsGranted;
1515

16-
#[Rest\Route('/executables')]
16+
#[Rest\Route(path: '/executables')]
1717
#[OA\Tag(name: 'Executables')]
1818
class ExecutableController extends AbstractFOSRestController
1919
{
@@ -26,7 +26,7 @@ public function __construct(protected readonly EntityManagerInterface $em, prote
2626
* @throws NonUniqueResultException
2727
*/
2828
#[IsGranted(new Expression("is_granted('ROLE_JURY') or is_granted('ROLE_JUDGEHOST')"))]
29-
#[Rest\Get('/{id}')]
29+
#[Rest\Get(path: '/{id}')]
3030
#[OA\Parameter(ref: '#/components/parameters/id')]
3131
#[OA\Response(
3232
response: 200,

webapp/src/Controller/API/GeneralInfoController.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(
5959
/**
6060
* Get the current API version
6161
*/
62-
#[Rest\Get('/version')]
62+
#[Rest\Get(path: '/version')]
6363
#[OA\Response(
6464
response: 200,
6565
description: 'The current API version information',
@@ -73,8 +73,8 @@ public function getVersionAction(): ApiVersion
7373
/**
7474
* Get information about the API and DOMjudge
7575
*/
76-
#[Rest\Get('/info')]
77-
#[Rest\Get('', name: 'api_root')]
76+
#[Rest\Get(path: '/info')]
77+
#[Rest\Get(path: '', name: 'api_root')]
7878
#[OA\Response(
7979
response: 200,
8080
description: 'Information about the API and DOMjudge',
@@ -115,7 +115,7 @@ public function getInfoAction(
115115
* @return ExtendedContestStatus[]
116116
*/
117117
#[IsGranted('ROLE_API_READER')]
118-
#[Rest\Get('/status')]
118+
#[Rest\Get(path: '/status')]
119119
#[OA\Response(
120120
response: 200,
121121
description: 'General status information for the currently active contests',
@@ -147,7 +147,7 @@ public function getStatusAction(): array
147147
* Get information about the currently logged in user.
148148
*/
149149
#[IsGranted('IS_AUTHENTICATED_FULLY')]
150-
#[Rest\Get('/user')]
150+
#[Rest\Get(path: '/user')]
151151
#[OA\Response(
152152
response: 200,
153153
description: 'Information about the logged in user',
@@ -163,7 +163,7 @@ public function getUserAction(): User
163163
*
164164
* @return array<string, bool|int|string|array<string, string>>
165165
*/
166-
#[Rest\Get('/config')]
166+
#[Rest\Get(path: '/config')]
167167
#[OA\Response(
168168
response: 200,
169169
description: 'The configuration variables',
@@ -206,7 +206,7 @@ public function getDatabaseConfigurationAction(
206206
* @throws NonUniqueResultException
207207
*/
208208
#[IsGranted('ROLE_ADMIN')]
209-
#[Rest\Put('/config')]
209+
#[Rest\Put(path: '/config')]
210210
#[OA\Response(
211211
response: 200,
212212
description: 'The full configuration after change',
@@ -244,7 +244,7 @@ public function updateConfigurationAction(Request $request): JsonResponse|array
244244
* Check the DOMjudge configuration.
245245
*/
246246
#[IsGranted('ROLE_ADMIN')]
247-
#[Rest\Get('/config/check')]
247+
#[Rest\Get(path: '/config/check')]
248248
#[OA\Response(
249249
response: 200,
250250
description: 'Result of the various checks performed, no problems found',
@@ -288,7 +288,7 @@ public function getConfigCheckAction(SerializerInterface $serializer): Response
288288
/**
289289
* Get the flag for the given country.
290290
*/
291-
#[Rest\Get('/country-flags/{countryCode}/{size}')]
291+
#[Rest\Get(path: '/country-flags/{countryCode}/{size}')]
292292
#[OA\Response(
293293
response: 200,
294294
description: 'Returns the given country flag in SVG format',
@@ -333,7 +333,7 @@ public function countryFlagAction(
333333
* @return array{problem_id: string, messages: array<string, string[]>}
334334
*/
335335
#[IsGranted('ROLE_ADMIN')]
336-
#[Rest\Post('/problems')]
336+
#[Rest\Post(path: '/problems')]
337337
#[OA\Tag(name: 'Problems')]
338338
#[OA\RequestBody(
339339
required: true,

0 commit comments

Comments
 (0)