API: Wrapped lists in data objects, specified datetime format

This commit is contained in:
Igor Scheller 2023-07-21 18:45:51 +02:00 committed by Michael Weimann
parent 1505d0229d
commit ca0a69b17d
3 changed files with 40 additions and 14 deletions

View File

@ -96,10 +96,14 @@ components:
description: True if the news should be highlightet and shown on the dashboard
created_at:
type: string
format: date-time
description: DateTime in ISO-8601 format
example: 2023-05-13T13:37:42.000000Z
updated_at:
type: string
nullable: true
format: date-time
description: DateTime in ISO-8601 format
example: 2023-05-13T23:00:00.000000Z
Room:
type: object
@ -124,9 +128,13 @@ components:
example: You clean up the venue after the event, its fun, we promise!
start:
type: string
format: date-time
description: DateTime in ISO-8601 format
example: 2023-05-13T14:00:00.000000Z
end:
type: string
format: date-time
description: DateTime in ISO-8601 format
example: 2023-05-13T16:00:00.000000Z23
entries:
type: array
@ -139,10 +147,14 @@ components:
created_at:
type: string
nullable: true
format: date-time
description: DateTime in ISO-8601 format
example: 2023-05-13T13:37:42.000000Z
updated_at:
type: string
nullable: true
format: date-time
description: DateTime in ISO-8601 format
example: 2023-05-13T23:00:00.000000Z
ShiftEntry:
type: object
@ -211,9 +223,12 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/AngelType'
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/AngelType'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
@ -230,9 +245,12 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/News'
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/News'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
@ -249,9 +267,12 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Room'
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Room'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':
@ -276,9 +297,12 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Shift'
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Shift'
'401':
$ref: '#/components/responses/UnauthorizedError'
'403':

View File

@ -64,7 +64,8 @@ class ApiController extends BaseController
->orderByDesc('created_at')
->get(['id', 'title', 'text', 'is_meeting', 'is_pinned', 'is_highlighted', 'created_at', 'updated_at']);
$data = ['data' => $news];
return $this->response
->withContent(json_encode($news));
->withContent(json_encode($data));
}
}

View File

@ -98,7 +98,8 @@ class ApiControllerTest extends ControllerTest
$this->assertJson($response->getContent());
$data = json_decode($response->getContent(), true);
$this->assertCount(3, $data);
$this->assertArrayHasKey('data', $data);
$this->assertCount(3, $data['data']);
}
public function setUp(): void