Skip to content

Commit ef5b557

Browse files
committed
Merge branch 'develop' into 3.x
2 parents 17f4ef4 + aa6eb5e commit ef5b557

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ All notable changes to this project will be documented in this file. This projec
1818
type, so anything could be sent. This is incorrect as the JSON:API specification shows the `Accept` header as
1919
`application/vnd.api+json` for [delete resource requests.](https://jsonapi.org/format/#crud-deleting)
2020

21+
## [2.5.2] - 2023-01-25
22+
23+
### Fixed
24+
25+
- [#225](https://github.com/laravel-json-api/laravel/issues/225) Fix validation of empty field list for a resource type
26+
in the `fields` query parameter, e.g. `/api/v1/employees?fields[employees]=`.
27+
2128
## [2.5.1] - 2023-01-23
2229

2330
### Fixed

tests/dummy/tests/Api/V1/Posts/ReadTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,35 @@ public function testSparseFieldSets(): void
180180
$response->assertFetchedOneExact($expected)->assertIncluded([$author]);
181181
}
182182

183+
/**
184+
* @return void
185+
* @see https://github.com/laravel-json-api/laravel/issues/225
186+
*/
187+
public function testSparseFieldSetsHasEmptyFieldList(): void
188+
{
189+
$post = Post::factory()->create();
190+
191+
$expected = $this->serializer
192+
->post($post)
193+
->only('author', 'slug', 'synopsis', 'title')
194+
->replace('author', ['type' => 'users', 'id' => $post->author]);
195+
196+
$author = $this->serializer
197+
->user($post->author)
198+
->withoutAttributes()
199+
->withoutRelationships();
200+
201+
$response = $this
202+
->withoutExceptionHandling()
203+
->jsonApi('posts')
204+
->sparseFields('posts', ['author', 'slug', 'synopsis', 'title'])
205+
->sparseFields('users', [])
206+
->includePaths('author')
207+
->get(url('/api/v1/posts', $expected['id']));
208+
209+
$response->assertFetchedOneExact($expected)->assertIncluded([$author]);
210+
}
211+
183212
public function testWithCount(): void
184213
{
185214
$post = Post::factory()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy