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

View File

@ -64,7 +64,8 @@ class ApiController extends BaseController
->orderByDesc('created_at') ->orderByDesc('created_at')
->get(['id', 'title', 'text', 'is_meeting', 'is_pinned', 'is_highlighted', 'created_at', 'updated_at']); ->get(['id', 'title', 'text', 'is_meeting', 'is_pinned', 'is_highlighted', 'created_at', 'updated_at']);
$data = ['data' => $news];
return $this->response 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()); $this->assertJson($response->getContent());
$data = json_decode($response->getContent(), true); $data = json_decode($response->getContent(), true);
$this->assertCount(3, $data); $this->assertArrayHasKey('data', $data);
$this->assertCount(3, $data['data']);
} }
public function setUp(): void public function setUp(): void