Skip to content

Commit 9807851

Browse files
authored
bugfix: do not wrap PolicyResource (#1211)
Fix bug where Laravel is wrapping the Resource response in a data object Bug: T432606
1 parent 365a84e commit 9807851

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

app/Http/Resources/PolicyResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class PolicyResource extends JsonResource {
1212
*
1313
* @return array<string, mixed>
1414
*/
15+
public static $wrap = null;
16+
1517
public function toArray(Request $request): array {
1618
return [
1719
'metadata' => [

tests/Http/Controllers/PolicyControllerTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public function testGetPolicyByTypeAndActiveFrom(): void {
2323
$request = $this->getJson('v1/policies/hosting-policy/by_active_from/2026-07-01');
2424

2525
$request->assertOk();
26+
$request->assertJsonStructure([
27+
'metadata' => [
28+
'policy_id',
29+
'active_from',
30+
'content_vue_file',
31+
'type',
32+
],
33+
]);
2634
$request->assertJsonFragment([
2735
'active_from' => '2026-07-01',
2836
'type' => 'hosting-policy',

0 commit comments

Comments
 (0)