8000 Merge branch 'release/3.0.0' · chris-doehring/laravel-json-api@bf58013 · GitHub
[go: up one dir, main page]

Skip to content

Commit bf58013

Browse files
committed
Merge branch 'release/3.0.0'
2 parents 0bd0953 + ea07d06 commit bf58013

File tree

78 files changed

+1008
-435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1008
-435
lines changed

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ sudo: false
44

55
matrix:
66
include:
7-
- php: "7.2"
8-
env:
9-
- LARAVEL_VERSION=^7.0
10-
- PHPUNIT_VERSION=^8.0
117
- php: "7.3"
128
env:
13-
- LARAVEL_VERSION=^7.0
9+
- LARAVEL_VERSION=^8.0
1410
- PHPUNIT_VERSION=^9.0
1511
- php: "7.4"
1612
env:
17-
- LARAVEL_VERSION=^7.0
13+
- LARAVEL_VERSION=^8.0
1814
- PHPUNIT_VERSION=^9.0
1915

2016
install:

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@
22
All notable changes to this project will be documented in this file. This project adheres to
33
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
44

5+
## [3.0.0] - 2020-09-09
6+
7+
### Added
8+
- [#545](https://github.com/cloudcreativity/laravel-json-api/issues/545)
9+
The request test builder now supports testing requests that do not have JSON API request content,
10+
but expect a JSON API response. For example, a file upload that results in a JSON API resource
11+
in the response body can be tested using:
12+
`$this->jsonApi()->asMultiPartFormData()->withPayload($data)->post('/api/v1/avatars');`.
13+
14+
### Changed
15+
- Minimum PHP version is now `7.3`.
16+
- Minimum Laravel version is now `8.0`.
17+
- [#497](https://github.com/cloudcreativity/laravel-json-api/issues/497) and
18+
[#529](https://github.com/cloudcreativity/laravel-json-api/pull/529)
19+
**BREAKING:** The method signature of the `AbstractValidators::rules()` method has changed,
20+
so that the method has access to the data that will be validated.
21+
- [#393](https://github.com/cloudcreativity/laravel-json-api/issues/393)
22+
**BREAKING:** when using the `SoftDeletesModel` trait on an adapter, the expected JSON API field
23+
for the soft delete attribute now defaults to the camel-case version of the model column. For example,
24+
column `deleted_at` previously defaulted to the JSON API field `deleted-at`, whereas now it will
25+
default to `deletedAt`. To continue to use dash-case, set the `softDeleteField` property on your adapter.
26+
27+
## [2.2.0] - 2020-09-09
28+
29+
### Added
30+
- [#549](https://github.com/cloudcreativity/laravel-json-api/issues/549)
31+
Can now add sort methods to an Eloquent adapter if sorting is more complex than just sorting by
32+
a column value.
33+
34+
### Fixed
35+
- The error translator will now detect if the translated value is identical to the translation
36+
key path, and return `null` when it is. This fixes behaviour that changed in Laravel 7.28.
37+
38+
## [2.1.0] - 2020-09-04
39+
40+
### Added
41+
- [#538](https://github.com/cloudcreativity/laravel-json-api/issues/538)
42+
New JSON API exception class that accepts the new error objects from this package.
43+
It is recommended that you use `CloudCreativity\LaravelJsonApi\Exceptions\JsonApiException`
44+
combined with the `CloudCreativity\LaravelJsonApi\Document\Error\Error`. It is not
45+
recommended to use the `Neomerx\JsonApi\Exceptions\JsonApiException` class as support
46+
for this exception class will be removed in a future version.
47+
548
## [2.0.0] - 2020-06-17
649

750
### Added

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright [yyyy] [name of copyright owner]
190+
Copyright 2020 Cloud Creativity Limited
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ A demo application is available at [here](https://github.com/cloudcreativity/dem
6262

6363
| Laravel | This Package |
6464
| --- | --- |
65+
| `^8.0` | `^3.0` |
6566
| `^7.0` | `^2.0` |
6667
| `^6.0` | `^1.7` |
6768
| `5.8.*` | `^1.7` |

composer.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,28 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^7.2",
25+
"php": "^7.3",
2626
"ext-json": "*",
27-
"illuminate/console": "^7.0",
28-
"illuminate/contracts": "^7.0",
29-
"illuminate/database": "^7.0",
30-
"illuminate/filesystem": "^7.0",
31-
"illuminate/http": "^7.0",
32-
"illuminate/pagination": "^7.0",
33-
"illuminate/support": "^7.0",
27+
"illuminate/console": "^8.0",
28+
"illuminate/contracts": "^8.0",
29+
"illuminate/database": "^8.0",
30+
"illuminate/filesystem": "^8.0",
31+
"illuminate/http": "^8.0",
32+
"illuminate/pagination": "^8.0",
33+
"illuminate/support": "^8.0",
3434
"neomerx/json-api": "^1.0.3",
3535
"nyholm/psr7": "^1.2",
3636
"ramsey/uuid": "^3.0|^4.0",
3737
"symfony/psr-http-message-bridge": "^2.0"
3838
},
3939
"require-dev": {
4040
"ext-sqlite3": "*",
41-
"cloudcreativity/json-api-testing": "^3.0",
42-
"guzzlehttp/guzzle": "^6.3",
41+
"cloudcreativity/json-api-testing": "^3.1",
42+
"guzzlehttp/guzzle": "^7.0",
43+
"laravel/legacy-factories": "^1.0.4",
4344
"laravel/ui": "^2.0",
4445
"mockery/mockery": "^1.1",
45-
"orchestra/testbench": "^5.0",
46+
"orchestra/testbench": "^6.0",
4647
"phpunit/phpunit": "^9.0"
4748
},
4849
"suggest": {
@@ -66,7 +67,7 @@
6667
},
6768
"extra": {
6869
"branch-alias": {
69-
"dev-develop": "2.x-dev"
70+
"dev-develop": "3.x-dev"
7071
},
7172
"laravel": {
7273
"providers": [

docs/basics/adapters.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,21 @@ If your resource supports client-generated ids, refer to the client-generated id
103103

104104
When filling a model with attributes received in a JSON API request, the adapter will convert the JSON API
105105
field name to either the snake case or camel case equivalent. For example, if your JSON API resource had
106-
an attribute field called `published-at`, this is mapped to `published_at` if your model uses snake case keys,
106+
an attribute field called `publishedAt`, this is mapped to `published_at` if your model uses snake case keys,
107107
or `publishedAt` if not.
108108

109109
> We work out whether your model uses snake case or camel case keys based on your model's `$snakeAttributes`
110110
static property.
111111

112112
If you have a JSON API field name that needs to map to a different model attribute, this can be defined in your
113-
adapter's `$attributes` property. For example, if the `published-at` field needed to be mapped to the
113+
adapter's `$attributes` property. For example, if the `publishedAt` field needed to be mapped to the
114114
`published_date` attribute on your model, it must be defined as follows:
115115

116116
```php
117117
class Adapter extends AbstractAdapter
118118
{
119119
protected $attributes = [
120-
'published-at' => 'published_date',
120+
'publishedAt' => 'published_date',
121121
];
122122

123123
// ...
@@ -132,25 +132,25 @@ you will protect any attributes that are not fillable using Eloquent's
132132

133133
There may be cases where an attribute is fillable on your model, but you do not want to allow your JSON API to
134134
fill it. You can set your adapter to skip attributes received from a client by listing the JSON API
135-
field name in the `$guarded` property on your adapter. For example, if we did not want the `published-at` field
135+
field name in the `$guarded` property on your adapter. For example, if we did not want the `publishedAt` field
136136
to be filled into our model, we would define it as follows:
137137

138138
```php
139139
class Adapter extends AbstractAdapter
140140
{
141-
protected $guarded = ['published-at'];
141+
protected $guarded = ['publishedAt'];
142142

143143
// ...
144144
}
145145
```
146146

147147
Alternatively, you can white-list JSON API fields that can be filled by adding them to the `$fillable` property
148-
on your adapter. For example, if we only wanted the `title`, `content` and `published-at` fields to be filled:
148+
on your adapter. For example, if we only wanted the `title`, `content` and `publishedAt` fields to be filled:
149149

150150
```php
151151
class Adapter extends AbstractAdapter
152152
{
153-
protected $fillable = ['title', 'content', 'published-at'];
153+
protected $fillable = ['title', 'content', 'publishedAt'];
154154

155155
// ...
156156
}
@@ -170,7 +170,7 @@ your adapter. For example:
170170
```php
171171
class Adapter extends AbstractAdapter
172172
{
173-
protected $dates = ['created-at', 'updated-at', 'published-at'];
173+
protected $dates = ['createdAt', 'updatedAt', 'publishedAt'];
174174

175175
// ...
176176
}

docs/basics/controllers.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ class PostsController extends JsonApiController
9090
9191
### Resource Hooks
9292

93-
The controller allows you to hook into the resource lifecycle by invoking the following methods if they are
94-
implemented. These methods allow you to easily implement application specific actions, such as firing events
93+
The controller allows you to hook into the resource lifecycle by invoking the following methods if they are
94+
implemented. These methods allow you to easily implement application specific actions, such as firing events
9595
or dispatching jobs.
9696

9797
| Hook | Arguments | Request Class |
@@ -106,12 +106,12 @@ or dispatching jobs.
106106
| `created` | record, request | `CreateResource` |
107107
| `saved` | record, request | `CreateResource` or `UpdateResource` |
108108
| `deleting` | record, request | `DeleteResource` |
109-
| `deleted` | record, request | `DeleteResource` |
109+
| `deleted` | record, request | `DeleteResource` |
110110

111111
> The request class is the validated request in the `CloudCreativity\LaravelJsonApi\Http\Requests` namespace.
112112
113113
The `searching`, `searched`, `reading` and `didRead` hooks are invoked when resource(s) are being accessed,
114-
i.e. a `GET` request. The `searching` and `searched` hooks are invoked when reading any resources
114+
i.e. a `GET` request. The `searching` and `searched` hooks are invoked when reading any resources
115115
(the *index* action), while `reading` and `didRead` are invoked when reading a specific record
116116
(the *read* action).
117117

@@ -158,7 +158,7 @@ if reading the `author` relationship on a `posts` resource, the `readingRelation
158158
methods will be invoked if they exist.
159159

160160
The `reading...` and `didRead...` methods are invoked when accessing the related resource or the relationship data,
161-
i.e. a `GET` relationship request. The `replacing...` and `replaced...` methods are invoked when changing the
161+
i.e. a `GET` relationship request. The `replacing...` and `replaced...` methods are invoked when changing the
162162
entire relationship in a `PATCH` relationship request.
163163

164164
For *to-many* relationships, the `adding...` and `added...` methods are invoked when adding resources to the
@@ -184,7 +184,7 @@ For example, if we wanted to send a `202 Accepted` response when a resource was
184184
protected function deleted($record)
185185
{
186186
return $this->reply()->meta([
187-
'accepted-at' => Carbon\Carbon::now()->toW3cString()
187+
'acceptedAt' => Carbon\Carbon::now(),
188188
], 202);
189189
}
190190
```
@@ -197,7 +197,7 @@ Content-Type: application/vnd.api+json
197197
198198
{
199199
"meta": {
200-
"accepted-at": "2018-04-10T11:56:52+00:00"
200+
"acceptedAt": "2018-04-10T11:56:52+00:00"
201201
}
202202
}
203203
```
@@ -224,11 +224,11 @@ use CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController;
224224

225225
class PostsController extends JsonApiController
226226
{
227-
227+
228228
public function share(\App\Post $post): \Illuminate\Http\Response
229229
{
230230
\App\Jobs\SharePost::dispatch($post);
231-
231+
232232
return $this->reply()->content($post);
233233
}
234234
}
@@ -257,11 +257,11 @@ use CloudCreativity\LaravelJsonApi\Http\Requests\FetchResource;
257257

258258
class PostsController extends JsonApiController
259259
{
260-
260+
261261
public function share(FetchResource $request, \App\Post $post): \Illuminate\Http\Response
262262
{
263263
\App\Jobs\SharePost::dispatch($post);
264-
264+
265265
return $this->reply()->content($post);
266266
}
267267
}

0 commit comments

Comments
 (0)
0