Skip to content

Commit fb7a4aa

Browse files
feat: Extend Swagger Coverage for controller ReleasesApiController
1 parent 09fc7e3 commit fb7a4aa

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

app/Http/Controllers/Apis/ReleasesApiController.php

Lines changed: 25 additions & 0 deletions
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/v1/releases/current',
49+
operationId: 'getCurrentRelease',
50+
description: 'Retrieve the current OpenStack release',
51+
tags: ['Releases'],
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();

app/Swagger/ReleasesSchemas.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
8+
#[OA\Schema(
9+
schema: 'OpenStackRelease',
10+
type: 'object',
11+
properties: [
12+
new OA\Property(property: 'id', type: 'integer', example: 1),
13+
new OA\Property(property: 'created', type: 'integer', description: 'Unix timestamp', example: 1630500518),
14+
new OA\Property(property: 'last_edited', type: 'integer', description: 'Unix timestamp', example: 1630500518),
15+
new OA\Property(property: 'name', type: 'string', example: 'Zed'),
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'),
19+
],
20+
anyOf: [
21+
new OA\Property(
22+
property: 'components',
23+
type: 'array',
24+
items: new OA\Items(type: 'integer'),
25+
description: 'Array of component IDs (only when not expanded)',
26+
example: [1, 2, 3]
27+
),
28+
new OA\Property(
29+
property: 'components',
30+
type: 'array',
31+
items: new OA\Items(type: 'SoftwareComponent'),
32+
description: 'Array of component objects (only when expanded with expand=components)'
33+
),
34+
]
35+
)]
36+
class OpenStackReleaseSchema {}

0 commit comments

Comments
 (0)