Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion app/Http/Controllers/Apis/TimezonesApiController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php namespace App\Http\Controllers;

/**
* Copyright 2021 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,6 +18,9 @@
use models\exceptions\EntityNotFoundException;
use models\exceptions\ValidationException;
use utils\PagingResponse;
use OpenApi\Attributes as OA;
use Symfony\Component\HttpFoundation\Response;

/**
* Class TimezonesApiController
* @package App\Http\Controllers
Expand All @@ -26,6 +30,32 @@ final class TimezonesApiController extends JsonController
/**
* @return mixed
*/
#[OA\Get(
path: '/api/public/v1/timezones',
operationId: 'getTimezones',
description: 'Retrieve all available timezones',
tags: ['Timezones (Public)'],
parameters: [
new OA\Parameter(
name: 'expand',
description: 'Expansion parameters',
in: 'query',
required: false,
schema: new OA\Schema(type: 'string')
),
],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: 'List of all available timezones',
content: new OA\JsonContent(ref: '#/components/schemas/TimezonesResponse')
),
new OA\Response(
response: Response::HTTP_INTERNAL_SERVER_ERROR,
description: 'Server Error'
),
]
)]
public function getAll(){
try {
$timezones = \DateTimeZone::listIdentifiers();
Expand Down Expand Up @@ -54,4 +84,4 @@ public function getAll(){
return $this->error500($ex);
}
}
}
}
36 changes: 36 additions & 0 deletions app/Swagger/TimezonesSchemas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace App\Swagger\schemas;

use OpenApi\Attributes as OA;

#[OA\Schema(
schema: 'TimezonesResponse',
type: 'object',
properties: [
new OA\Property(
property: 'data',
type: 'array',
items: new OA\Items(type: 'string', example: 'America/New_York'),
description: 'Array of all available timezone identifiers'
),
new OA\Property(
property: 'total',
type: 'integer',
example: 427,
description: 'Total number of available timezones'
),
new OA\Property(
property: 'current_page',
type: 'integer',
example: 1,
description: 'Current page number'
),
new OA\Property(
property: 'last_page',
type: 'integer',
example: 1,
description: 'Last page number'
),
]
)]
class TimezonesResponseSchema {}