8000 Merge branch 'release/1.0.0-alpha.1' · tekord/laravel-json-api@8422384 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 17, 2023. It is now read-only.

Commit 8422384

Browse files
committed
Merge branch 'release/1.0.0-alpha.1'
2 parents 61b06f7 + 1295fda commit 8422384

File tree

370 files changed

+34657
-5948
lines changed

Some content is hidden

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

370 files changed

+34657
-5948
lines changed

CHANGELOG.md

Lines changed: 56 additions & 308 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@
2323
],
2424
"require": {
2525
"php": "^5.6|^7.0",
26-
"cloudcreativity/json-api": "^0.11",
26+
"cloudcreativity/utils-object": "^1.0",
2727
"illuminate/console": "5.4.*|5.5.*|5.6.*",
2828
"illuminate/contracts": "5.4.*|5.5.*|5.6.*",
2929
"illuminate/database": "5.4.*|5.5.*|5.6.*",
3030
"illuminate/filesystem": "5.4.*|5.5.*|5.6.*",
3131
"illuminate/http": "5.4.*|5.5.*|5.6.*",
3232
"illuminate/pagination": "5.4.*|5.5.*|5.6.*",
3333
"illuminate/support": "5.4.*|5.5.*|5.6.*",
34+
"neomerx/json-api": "^1.0.3",
3435
"symfony/psr-http-message-bridge": "^1.0",
3536
"zendframework/zend-diactoros": "^1.3"
3637
},
3738
"require-dev": {
3839
"ext-sqlite3": "*",
39-
"cloudcreativity/json-api-testing": "^0.3",
40+
"cloudcreativity/json-api-testing": "^0.4",
41+
"guzzlehttp/guzzle": "^6.3",
4042
"orchestra/testbench": "3.4.*|3.5.*|3.6.*",
4143
"phpunit/phpunit": "^5.7|^6.0|^7.0"
4244
},
@@ -53,12 +55,14 @@
5355
},
5456
"autoload-dev": {
5557
"psr-4": {
56-
"CloudCreativity\\LaravelJsonApi\\Tests\\": "tests/"
58+
"DummyApp\\": "tests/dummy/app",
59+
"CloudCreativity\\LaravelJsonApi\\Tests\\": "tests/lib",
60+
"DummyPackage\\": "tests/package/src"
5761
}
5862
},
5963
"extra": {
6064
"branch-alias": {
61-
"dev-develop": "0.13.x-dev"
65+
"dev-develop": "1.x-dev"
6266
},
6367
"laravel": {
6468
"providers": [

config/json-api-errors.php

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,60 @@
11
<?php
2-
3-
use CloudCreativity\JsonApi\Contracts\Document\MutableErrorInterface as Error;
4-
use CloudCreativity\JsonApi\Validators\ValidatorErrorFactory as V;
2+
/**
3+
* Copyright 2018 Cloud Creativity Limited
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
use CloudCreativity\LaravelJsonApi\Contracts\Document\MutableErrorInterface as Error;
19+
use CloudCreativity\LaravelJsonApi\Http\Headers\RestrictiveHeadersChecker as H;
20+
use CloudCreativity\LaravelJsonApi\Validators\ValidatorErrorFactory as V;
21+
use Illuminate\Http\Response;
522

623
return [
724

25+
/**
26+
* The client's `Accept` header does not a configured encoder.
27+
*/
28+
H::NOT_ACCEPTABLE => [
29+
Error::TITLE => 'Not Acceptable',
30+
Error::STATUS => Response::HTTP_NOT_ACCEPTABLE,
31+
],
32+
33+
/**
34+
* The client's `Content-Type` header contains multiple media types, so we do not
35+
* know which media type to match against.
36+
*/
37+
H::MULTIPLE_MEDIA_TYPES => [
38+
Error::TITLE => 'Invalid Content-Type Header',
39+
Error::STATUS => Response::HTTP_BAD_REQUEST,
40+
],
41+
42+
/**
43+
* The client's `Content-Type` header does not match a configured decoder.
44+
*/
45+
H::UNSUPPORTED_MEDIA_TYPE => [
46+
Error::TITLE => 'Invalid Content-Type Header',
47+
Error::STATUS => Response::HTTP_UNSUPPORTED_MEDIA_TYPE,
48+
Error::DETAIL => 'The specified content type is not supported.',
49+
],
50+
851
/**
952
* A compulsory member has not been included in document.
1053
*/
1154
V::MEMBER_REQUIRED => [
1255
Error::TITLE => 'Required Member',
1356
Error::DETAIL => "The member '{member}' is required.",
14-
Error::STATUS => 400,
57+
Error::STATUS => Response::HTTP_BAD_REQUEST,
1558
],
1659

1760
/**
@@ -20,7 +63,7 @@
2063
V::MEMBER_OBJECT_EXPECTED => [
2164
Error::TITLE => 'Object Expected',
2265
Error::DETAIL => "The member '{member}' must be an object.",
23-
Error::STATUS => 400,
66+
Error::STATUS => Response::HTTP_BAD_REQUEST,
2467
],
2568

2669
/**
@@ -30,7 +73,7 @@
3073
V::MEMBER_STRING_EXPECTED => [
3174
Error::TITLE => 'String Expected',
3275
Error::DETAIL => "The member '{member}' must be a string.",
33-
Error::STATUS => 400,
76+
Error::STATUS => Response::HTTP_BAD_REQUEST,
3477
],
3578

3679
/**
@@ -39,7 +82,7 @@
3982
V::MEMBER_EMPTY_NOT_ALLOWED => [
4083
Error::TITLE => 'Value Expected',
4184
Error::DETAIL => "The member '{member}' cannot be empty.",
42-
Error::STATUS => 400,
85+
Error::STATUS => Response::HTTP_BAD_REQUEST,
4386
],
4487

4588
/**
@@ -48,7 +91,7 @@
4891
V::MEMBER_RELATIONSHIP_EXPECTED => [
4992
Error::TITLE => 'Relationship Expected',
5093
Error::DETAIL => "The member '{member}' must be a relationship object.",
51-
Error::STATUS => 400,
94+
Error::STATUS => Response::HTTP_BAD_REQUEST,
5295
],
5396

5497
/**
@@ -75,7 +118,7 @@
75118
V::RESOURCE_INVALID_ATTRIBUTES => [
76119
Error::TITLE => 'Invalid Attributes',
77120
Error::DETAIL => 'The attributes member is invalid.',
78-
Error::STATUS => 400,
121+
Error::STATUS => Response::HTTP_BAD_REQUEST,
79122
],
80123

81124
/**
@@ -85,7 +128,7 @@
85128
*/
86129
V::RESOURCE_INVALID_ATTRIBUTES_MESSAGES => [
87130
Error::TITLE => 'Invalid Attribute',
88-
Error::STATUS => 422,
131+
Error::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY,
89132
],
90133

91134
/**
@@ -94,7 +137,7 @@
94137
V::RESOURCE_INVALID_RELATIONSHIPS => [
95138
Error::TITLE => 'Invalid Relationships',
96139
Error::DETAIL => 'The relationships member is invalid.',
97-
Error::STATUS => 400,
140+
Error::STATUS => Response::HTTP_BAD_REQUEST,
98141
],
99142

100143
/**
@@ -103,7 +146,7 @@
103146
V::RELATIONSHIP_HAS_ONE_EXPECTED => [
104147
Error::TITLE => 'Invalid Relationship',
105148
Error::DETAIL => 'The provided relationship must be a has-one relationship',
106-
Error::STATUS => 400,
149+
Error::STATUS => Response::HTTP_BAD_REQUEST,
107150
],
108151

109152
/**
@@ -112,7 +155,7 @@
112155
V::RELATIONSHIP_HAS_MANY_EXPECTED => [
113156
Error::TITLE => 'Invalid Relationship',
114157
Error::DETAIL => 'The provided relationship must be a has-many relationship',
115-
Error::STATUS => 400,
158+
Error::STATUS => Response::HTTP_BAD_REQUEST,
116159
],
117160

118161
/**
@@ -121,7 +164,7 @@
121164
V::RELATIONSHIP_EMPTY_NOT_ALLOWED => [
122165
Error::TITLE => 'Invalid Relationship',
123166
Error::DETAIL => 'The provided relationship cannot be empty.',
124-
Error::STATUS => 422,
167+
Error::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY,
125168
],
126169

127170
/**
@@ -139,7 +182,7 @@
139182
V::RELATIONSHIP_NOT_ACCEPTABLE => [
140183
Error::TITLE => 'Invalid Relationship',
141184
Error::DETAIL => 'The related resource is not acceptable.',
142-
Error::STATUS => 422,
185+
Error::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY,
143186
],
144187

145188
/**
@@ -148,7 +191,7 @@
148191
V::RELATIONSHIP_UNKNOWN_TYPE => [
149192
Error::TITLE => 'Invalid Relationship',
150193
Error::DETAIL => "Resource type '{actual}' is not recognised.",
151-
Error::STATUS => 400,
194+
Error::STATUS => Response::HTTP_BAD_REQUEST,
152195
],
153196

154197
/**
@@ -157,7 +200,7 @@
157200
V::RELATIONSHIP_UNSUPPORTED_TYPE => [
158201
Error::TITLE => 'Invalid Relationship',
159202
Error::DETAIL => "Resource '{actual}' is not among the type(s) supported by this relationship. Expecting only '{expected}' resources.",
160-
Error::STATUS => 400,
203+
Error::STATUS => Response::HTTP_BAD_REQUEST,
161204
],
162205

163206
/**
@@ -167,7 +210,7 @@
167210
*/
168211
V::QUERY_PARAMETERS_MESSAGES => [
169212
Error::TITLE => 'Invalid Query Parameter',
170-
Error::STATUS => 400,
213+
Error::STATUS => Response::HTTP_BAD_REQUEST,
171214
],
172215

173216
/**
@@ -179,6 +222,6 @@
179222
*/
180223
Exception::class => [
181224
Error::TITLE => 'Internal Server Error',
182-
Error::STATUS => 500,
225+
Error::STATUS => Response::HTTP_INTERNAL_SERVER_ERROR,
183226
],
184227
];

0 commit comments

Comments
 (0)
0