File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ throw new ApiProblemException(
4040- [ NotFoundProblem] ( #notfoundproblem )
4141- [ UnauthorizedProblem] ( #unauthorizedproblem )
4242- [ ValidationApiProblem] ( #validationapiproblem )
43+ - [ BadRequestProblem] ( #badrequestproblem )
4344
4445#### ExceptionApiProblem
4546
@@ -188,10 +189,27 @@ new ValidationApiProblem(new ConstraintViolationList([
188189}
189190````
190191
192+ #### BadRequestProblem
193+
194+ ```php
195+ use Phpro\ApiProblem\Http\BadRequestProblem;
196+
197+ new BadRequestProblem('You are not authorized to access X.');
198+ ```
199+
200+ ``` json
201+ {
202+ "status" : 400 ,
203+ "type" : " http:\/\/ www.w3.org\/ Protocols\/ rfc2616\/ rfc2616-sec10.html" ,
204+ "title" : " Bad Request" ,
205+ "detail" : " Bad request. Bad!"
206+ }
207+ ````
208+
191209
192210### Creating your own problem
193211
194- Creating problem sounds scarry right!?
212+ Creating problem sounds scary right!?
195213Since the RFC is very loose, we made the interface as easy as possible:
196214
197215```php
@@ -238,7 +256,7 @@ class MyProblem implements DebuggableApiProblemInterface
238256 return [
239257 'type' => 'about:blank',
240258 'status' => '99',
241- 'title' => 'Got 99 problems but a glitch aint one!',
259+ 'title' => 'Got 99 problems but a glitch ain\'t one!',
242260 ];
243261 }
244262
You can’t perform that action at this time.
0 commit comments