diff --git a/resources/api/openapi.yml b/resources/api/openapi.yml index 85f4dda1..1f9eeedf 100644 --- a/resources/api/openapi.yml +++ b/resources/api/openapi.yml @@ -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': diff --git a/src/Controllers/ApiController.php b/src/Controllers/ApiController.php index 2c5a4c9c..4ed54910 100644 --- a/src/Controllers/ApiController.php +++ b/src/Controllers/ApiController.php @@ -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)); } } diff --git a/tests/Unit/Controllers/ApiControllerTest.php b/tests/Unit/Controllers/ApiControllerTest.php index 4818bfe3..12dce380 100644 --- a/tests/Unit/Controllers/ApiControllerTest.php +++ b/tests/Unit/Controllers/ApiControllerTest.php @@ -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