Skip to content

Commit e02ae95

Browse files
Feature | Extend Swagger Coverage for controller ReleasesApiController (#379)
* feat: Extend Swagger Coverage for controller ReleasesApiController * fix: move OpenStackRelease schema to its own file, remove previous definition and fix incorrect route --------- Co-authored-by: Matias Perrone <github@matiasperrone.com>
1 parent 7d1b6aa commit e02ae95

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

app/Http/Controllers/Apis/ReleasesApiController.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Illuminate\Support\Facades\Log;
1818
use models\oauth2\IResourceServerContext;
1919
use ModelSerializers\SerializerRegistry;
20+
use OpenApi\Attributes as OA;
21+
use Symfony\Component\HttpFoundation\Response;
2022

2123
/**
2224
* Class ReleasesApiController
@@ -42,6 +44,29 @@ public function __construct
4244
/**
4345
* @return \Illuminate\Http\JsonResponse|mixed|void
4446
*/
47+
#[OA\Get(
48+
path: '/api/public/v1/releases/current',
49+
operationId: 'getCurrentRelease',
50+
description: 'Retrieve the current OpenStack release',
51+
tags: ['Releases (Public)'],
52+
responses: [
53+
new OA\Response(
54+
response: Response::HTTP_OK,
55+
description: 'Current OpenStack release',
56+
content: new OA\JsonContent(
57+
ref: '#/components/schemas/OpenStackRelease'
58+
)
59+
),
60+
new OA\Response(
61+
response: Response::HTTP_NOT_FOUND,
62+
description: 'Current release not found'
63+
),
64+
new OA\Response(
65+
response: Response::HTTP_INTERNAL_SERVER_ERROR,
66+
description: 'Server Error'
67+
),
68+
]
69+
)]
4570
public function getCurrent(){
4671
try{
4772
$current = $this->repository->getCurrent();
@@ -57,4 +82,4 @@ public function getCurrent(){
5782
return $this->error500($ex);
5883
}
5984
}
60-
}
85+
}

app/Swagger/Models/OpenStackReleaseSchema.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
new OA\Property(property: 'created', type: 'integer', example: 1),
1414
new OA\Property(property: 'last_edited', type: 'integer', example: 1),
1515
new OA\Property(property: 'name', type: 'string'),
16+
new OA\Property(property: 'release_number', type: 'string', example: '2024.2'),
17+
new OA\Property(property: 'release_date', type: 'integer', description: 'Unix timestamp', example: 1729123200),
18+
new OA\Property(property: 'status', type: 'string', example: 'current'),
1619
new OA\Property(property: 'components', type: 'array', items: new OA\Items(
1720
oneOf: [
1821
new OA\Schema(type: 'integer'),
@@ -23,4 +26,4 @@
2326
]
2427
class OpenStackReleaseSchema
2528
{
26-
}
29+
}

app/Swagger/ReleasesSchemas.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+

0 commit comments

Comments
 (0)