From c98b054118934b2e1349ccb11db4f3202a657891 Mon Sep 17 00:00:00 2001 From: Thomas Arrow Date: Mon, 20 Jul 2026 16:11:50 +0100 Subject: [PATCH] bugfix: do not wrap PolicyResource Fix bug where Laravel is wrapping the Resource response in a data object Bug: T432606 --- app/Http/Resources/PolicyResource.php | 2 ++ tests/Http/Controllers/PolicyControllerTest.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/Http/Resources/PolicyResource.php b/app/Http/Resources/PolicyResource.php index a3061ec3..40b5fa8c 100644 --- a/app/Http/Resources/PolicyResource.php +++ b/app/Http/Resources/PolicyResource.php @@ -12,6 +12,8 @@ class PolicyResource extends JsonResource { * * @return array */ + public static $wrap = null; + public function toArray(Request $request): array { return [ 'metadata' => [ diff --git a/tests/Http/Controllers/PolicyControllerTest.php b/tests/Http/Controllers/PolicyControllerTest.php index b3527248..56829d65 100644 --- a/tests/Http/Controllers/PolicyControllerTest.php +++ b/tests/Http/Controllers/PolicyControllerTest.php @@ -23,6 +23,14 @@ public function testGetPolicyByTypeAndActiveFrom(): void { $request = $this->getJson('v1/policies/hosting-policy/by_active_from/2026-07-01'); $request->assertOk(); + $request->assertJsonStructure([ + 'metadata' => [ + 'policy_id', + 'active_from', + 'content_vue_file', + 'type', + ], + ]); $request->assertJsonFragment([ 'active_from' => '2026-07-01', 'type' => 'hosting-policy',