Skip to content

Commit 39c4941

Browse files
committed
fix: add requested changes and remove incorrectly added code and restore original linting
Signed-off-by: Matias Perrone <github@matiasperrone.com>
1 parent ed65c59 commit 39c4941

File tree

4 files changed

+161
-210
lines changed

4 files changed

+161
-210
lines changed

app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitMediaUploadTypeApiController.php

Lines changed: 71 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php
2-
3-
namespace App\Http\Controllers;
1+
<?php namespace App\Http\Controllers;
42

53
/**
64
* Copyright 2020 OpenStack Foundation
@@ -63,7 +61,8 @@ public function __construct
6361
ISummitRepository $summit_repository,
6462
ISummitMediaUploadTypeService $service,
6563
IResourceServerContext $resource_server_context
66-
) {
64+
)
65+
{
6766
parent::__construct($resource_server_context);
6867
$this->service = $service;
6968
$this->summit_repository = $summit_repository;
@@ -72,6 +71,7 @@ public function __construct
7271

7372
#[OA\Get(
7473
path: "/api/v1/summits/{id}/media-upload-types",
74+
operationId: "getAllMediaUploadTypes",
7575
summary: "Get all media upload types for a summit",
7676
description: "Returns a paginated list of media upload types configured for a specific summit. Allows ordering, filtering and pagination.",
7777
security: [
@@ -91,9 +91,9 @@ public function __construct
9191
tags: ["Summit Media Upload Types"],
9292
parameters: [
9393
new OA\Parameter(
94-
name: 'summit_id',
95-
in: 'query',
96-
required: false,
94+
name: 'id',
95+
in: 'path',
96+
required: true,
9797
schema: new OA\Schema(type: 'integer'),
9898
description: 'The summit ID'
9999
),
@@ -150,20 +150,14 @@ public function __construct
150150
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
151151
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
152152
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
153-
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Summit not found"),
153+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Summit Not Found"),
154154
]
155155
)]
156-
public function getAllBySummit($summit_id)
157-
{
158-
$this->summit_id = $summit_id;
159-
$summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->getResourceServerContext())->find($this->summit_id);
160-
if (is_null($summit))
161-
return $this->error404();
162-
return $this->getAll();
163-
}
156+
// public function getAllBySummit($summit_id)
164157

165158
#[OA\Get(
166159
path: "/api/v1/summits/{id}/media-upload-types/{media_upload_type_id}",
160+
operationId: "getMediaUploadType",
167161
summary: "Get a specific media upload type",
168162
description: "Returns detailed information about a specific media upload type",
169163
security: [
@@ -183,9 +177,9 @@ public function getAllBySummit($summit_id)
183177
tags: ["Summit Media Upload Types"],
184178
parameters: [
185179
new OA\Parameter(
186-
name: 'summit_id',
187-
in: 'query',
188-
required: false,
180+
name: 'id',
181+
in: 'path',
182+
required: true,
189183
schema: new OA\Schema(type: 'integer'),
190184
description: 'The summit ID'
191185
),
@@ -219,16 +213,14 @@ public function getAllBySummit($summit_id)
219213
),
220214
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
221215
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
222-
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
216+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
223217
]
224218
)]
225-
public function get($summit_id, $media_upload_type_id)
226-
{
227-
return $this->getById($summit_id, $media_upload_type_id);
228-
}
219+
// public function get($summit_id, $media_upload_type_id)
229220

230221
#[OA\Post(
231222
path: "/api/v1/summits/{id}/media-upload-types",
223+
operationId: "createMediaUploadType",
232224
summary: "Create a new media upload type",
233225
description: "Creates a new media upload type for the specified summit",
234226
security: [
@@ -248,9 +240,9 @@ public function get($summit_id, $media_upload_type_id)
248240
tags: ["Summit Media Upload Types"],
249241
parameters: [
250242
new OA\Parameter(
251-
name: 'summit_id',
252-
in: 'query',
253-
required: false,
243+
name: 'id',
244+
in: 'path',
245+
required: true,
254246
schema: new OA\Schema(type: 'integer'),
255247
description: 'The summit ID'
256248
),
@@ -268,17 +260,15 @@ public function get($summit_id, $media_upload_type_id)
268260
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
269261
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
270262
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
271-
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Summit not found"),
263+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Summit Not Found"),
272264
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
273265
]
274266
)]
275-
public function add($summit_id)
276-
{
277-
return $this->addChild($summit_id);
278-
}
267+
// public function add($summit_id)
279268

280269
#[OA\Put(
281270
path: "/api/v1/summits/{id}/media-upload-types/{media_upload_type_id}",
271+
operationId: "updateMediaUploadType",
282272
summary: "Update a media upload type",
283273
description: "Updates an existing media upload type",
284274
security: [
@@ -298,9 +288,9 @@ public function add($summit_id)
298288
tags: ["Summit Media Upload Types"],
299289
parameters: [
300290
new OA\Parameter(
301-
name: 'summit_id',
302-
in: 'query',
303-
required: false,
291+
name: 'id',
292+
in: 'path',
293+
required: true,
304294
schema: new OA\Schema(type: 'integer'),
305295
description: 'The summit ID'
306296
),
@@ -325,17 +315,15 @@ public function add($summit_id)
325315
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
326316
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
327317
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
328-
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
318+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
329319
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
330320
]
331321
)]
332-
public function update($summit_id, $media_upload_type_id)
333-
{
334-
return $this->updateChild($summit_id, $media_upload_type_id);
335-
}
322+
// public function update($summit_id, $media_upload_type_id)
336323

337324
#[OA\Delete(
338325
path: "/api/v1/summits/{id}/media-upload-types/{media_upload_type_id}",
326+
operationId: "deleteMediaUploadType",
339327
summary: "Delete a media upload type",
340328
description: "Deletes a media upload type from the summit",
341329
security: [
@@ -355,9 +343,9 @@ public function update($summit_id, $media_upload_type_id)
355343
tags: ["Summit Media Upload Types"],
356344
parameters: [
357345
new OA\Parameter(
358-
name: 'summit_id',
359-
in: 'query',
360-
required: false,
346+
name: 'id',
347+
in: 'path',
348+
required: true,
361349
schema: new OA\Schema(type: 'integer'),
362350
description: 'The summit ID'
363351
),
@@ -373,18 +361,15 @@ public function update($summit_id, $media_upload_type_id)
373361
new OA\Response(response: Response::HTTP_NO_CONTENT, description: "Deleted successfully"),
374362
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
375363
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
376-
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
364+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
377365
]
378366
)]
379-
public function delete($summit_id, $media_upload_type_id)
380-
{
381-
return $this->deleteChild($summit_id, $media_upload_type_id);
382-
}
367+
// public function delete($summit_id, $media_upload_type_id)
383368

384369
/**
385370
* @return array
386371
*/
387-
protected function getFilterRules(): array
372+
protected function getFilterRules():array
388373
{
389374
return [
390375
'name' => ['=@', '=='],
@@ -394,17 +379,15 @@ protected function getFilterRules(): array
394379
/**
395380
* @return array
396381
*/
397-
protected function getFilterValidatorRules(): array
398-
{
382+
protected function getFilterValidatorRules():array{
399383
return [
400384
'name' => 'sometimes|required|string',
401385
];
402386
}
403387
/**
404388
* @return array
405389
*/
406-
protected function getOrderRules(): array
407-
{
390+
protected function getOrderRules():array{
408391
return [
409392
'id',
410393
'name',
@@ -504,6 +487,7 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I
504487

505488
#[OA\Put(
506489
path: "/api/v1/summits/{id}/media-upload-types/{media_upload_type_id}/presentation-types/{event_type_id}",
490+
operationId: "addMediaUploadTypeToPresentationType",
507491
summary: "Add media upload type to presentation type",
508492
description: "Associates a media upload type with a specific presentation type",
509493
security: [
@@ -523,9 +507,9 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I
523507
tags: ["Summit Media Upload Types"],
524508
parameters: [
525509
new OA\Parameter(
526-
name: 'summit_id',
527-
in: 'query',
528-
required: false,
510+
name: 'id',
511+
in: 'path',
512+
required: true,
529513
schema: new OA\Schema(type: 'integer'),
530514
description: 'The summit ID'
531515
),
@@ -552,15 +536,19 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I
552536
),
553537
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
554538
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
555-
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
539+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
556540
]
557541
)]
558-
public function addToPresentationType($summit_id, $media_upload_type_id, $presentation_type_id)
559-
{
542+
/**
543+
* @param $summit_id
544+
* @param $media_upload_type_id
545+
* @param $presentation_type_id
546+
* @return \Illuminate\Http\JsonResponse|mixed
547+
*/
548+
public function addToPresentationType($summit_id, $media_upload_type_id, $presentation_type_id){
560549
return $this->processRequest(function () use ($summit_id, $media_upload_type_id, $presentation_type_id) {
561550
$summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->getResourceServerContext())->find($summit_id);
562-
if (is_null($summit))
563-
return $this->error404();
551+
if (is_null($summit)) return $this->error404();
564552

565553
// authz
566554
// check that we have a current member ( not service account )
@@ -582,6 +570,7 @@ public function addToPresentationType($summit_id, $media_upload_type_id, $presen
582570

583571
#[OA\Delete(
584572
path: "/api/v1/summits/{id}/media-upload-types/{media_upload_type_id}/presentation-types/{event_type_id}",
573+
operationId: "removeMediaUploadTypeFromPresentationType",
585574
summary: "Remove media upload type from presentation type",
586575
description: "Removes the association between a media upload type and a presentation type",
587576
security: [
@@ -601,9 +590,9 @@ public function addToPresentationType($summit_id, $media_upload_type_id, $presen
601590
tags: ["Summit Media Upload Types"],
602591
parameters: [
603592
new OA\Parameter(
604-
name: 'summit_id',
605-
in: 'query',
606-
required: false,
593+
name: 'id',
594+
in: 'path',
595+
required: true,
607596
schema: new OA\Schema(type: 'integer'),
608597
description: 'The summit ID'
609598
),
@@ -630,15 +619,19 @@ public function addToPresentationType($summit_id, $media_upload_type_id, $presen
630619
),
631620
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
632621
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
633-
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
622+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
634623
]
635624
)]
636-
public function deleteFromPresentationType($summit_id, $media_upload_type_id, $presentation_type_id)
637-
{
625+
/**
626+
* @param $summit_id
627+
* @param $media_upload_type_id
628+
* @param $presentation_type_id
629+
* @return \Illuminate\Http\JsonResponse|mixed
630+
*/
631+
public function deleteFromPresentationType($summit_id, $media_upload_type_id, $presentation_type_id){
638632
return $this->processRequest(function () use ($summit_id, $media_upload_type_id, $presentation_type_id) {
639633
$summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->getResourceServerContext())->find($summit_id);
640-
if (is_null($summit))
641-
return $this->error404();
634+
if (is_null($summit)) return $this->error404();
642635

643636
// authz
644637
// check that we have a current member ( not service account )
@@ -659,6 +652,7 @@ public function deleteFromPresentationType($summit_id, $media_upload_type_id, $p
659652

660653
#[OA\Post(
661654
path: "/api/v1/summits/{id}/media-upload-types/all/clone/{to_summit_id}",
655+
operationId: "cloneMediaUploadTypes",
662656
summary: "Clone media upload types to another summit",
663657
description: "Clones all media upload types from one summit to another summit",
664658
security: [
@@ -678,9 +672,9 @@ public function deleteFromPresentationType($summit_id, $media_upload_type_id, $p
678672
tags: ["Summit Media Upload Types"],
679673
parameters: [
680674
new OA\Parameter(
681-
name: 'summit_id',
682-
in: 'query',
683-
required: false,
675+
name: 'id',
676+
in: 'path',
677+
required: true,
684678
schema: new OA\Schema(type: 'integer'),
685679
description: 'The summit ID'
686680
),
@@ -696,23 +690,20 @@ public function deleteFromPresentationType($summit_id, $media_upload_type_id, $p
696690
new OA\Response(
697691
response: Response::HTTP_CREATED,
698692
description: "Success - Returns the target summit with cloned media upload types",
699-
content: new OA\JsonContent(type: "object")
693+
content: new OA\JsonContent(ref: "#/components/schemas/Summit")
700694
),
701695
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
702696
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
703-
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Source or target summit not found"),
697+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Source or target summit Not Found"),
704698
]
705699
)]
706-
public function cloneMediaUploadTypes($summit_id, $to_summit_id)
707-
{
700+
public function cloneMediaUploadTypes($summit_id, $to_summit_id){
708701
return $this->processRequest(function () use ($summit_id, $to_summit_id) {
709702
$summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->getResourceServerContext())->find($summit_id);
710-
if (is_null($summit))
711-
return $this->error404();
703+
if (is_null($summit)) return $this->error404();
712704

713705
$to_summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->getResourceServerContext())->find($to_summit_id);
714-
if (is_null($to_summit))
715-
return $this->error404();
706+
if (is_null($to_summit)) return $this->error404();
716707

717708
// authz
718709
// check that we have a current member ( not service account )
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
8+
#[OA\Schema(
9+
schema: 'SummitMediaFileType',
10+
type: 'object',
11+
properties: [
12+
new OA\Property(property: 'id', type: 'integer', example: 1),
13+
new OA\Property(property: 'created', type: 'integer', format: 'int64', example: 1633024800),
14+
new OA\Property(property: 'last_edited', type: 'integer', format: 'int64', example: 1633024800),
15+
new OA\Property(property: 'name', type: 'string', example: 'Presentation'),
16+
new OA\Property(property: 'description', type: 'string', example: 'Presentation files for events'),
17+
new OA\Property(property: 'is_system_defined', type: 'boolean', example: false),
18+
new OA\Property(
19+
property: 'allowed_extensions',
20+
type: 'array',
21+
items: new OA\Items(type: 'string'),
22+
example: ['pdf', 'ppt', 'pptx']
23+
),
24+
]
25+
)]
26+
class SummitMediaFileTypeSchema {}

0 commit comments

Comments
 (0)