Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
👷 Set http delete in revoke functions, add progress in swagger
Browse files Browse the repository at this point in the history
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
  • Loading branch information
lloricode committed Sep 12, 2020
1 parent 1009847 commit 8e14337
Show file tree
Hide file tree
Showing 16 changed files with 346 additions and 280 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public/docs/*
composer.phar
.phpunit.result.cache
/storage/api-docs
build
.build
13 changes: 12 additions & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
use Illuminate\Database\QueryException;
use Illuminate\Validation\ValidationException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthServerException;
use League\OAuth2\Server\Exception\OAuthServerException as LeagueOAuthServerException;
use Spatie\Permission\Exceptions\RoleAlreadyExists;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable;

class Handler extends ExceptionHandler
Expand All @@ -24,6 +27,8 @@ class Handler extends ExceptionHandler
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
LeagueOAuthServerException::class,
LaravelOAuthServerException::class,
];

/**
Expand Down Expand Up @@ -52,7 +57,13 @@ public function report(Throwable $exception)
*/
public function render($request, Throwable $exception)
{
if ($exception instanceof RoleAlreadyExists) {
if (method_exists($exception, 'getStatusCode') && blank($exception->getMessage())) {
if ($exception->getStatusCode() == Response::HTTP_NOT_FOUND) {
$exception = new NotFoundHttpException('404 Not Found', $exception);
} else {
$exception = new HttpException($exception->getStatusCode(), 'Error '.$exception->getStatusCode());
}
} elseif ($exception instanceof RoleAlreadyExists) {
$exception = new HttpException(
Response::HTTP_UNPROCESSABLE_ENTITY,
$exception->getMessage(),
Expand Down
18 changes: 17 additions & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Controller extends BaseController
* @OA\Post(
* path="/oauth/token",
* summary="Generate access token",
* tags={"Authorization"},
* tags={"Authentication"},
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="application/json",
Expand Down Expand Up @@ -106,14 +106,30 @@ class Controller extends BaseController
* )
*
* @OA\Tag(
* name="Authentication",
* description="API Endpoints of Authentication"
* )
* @OA\Tag(
* name="Authorization",
* description="API Endpoints of Authorization"
* )
* @OA\Tag(
* name="Localizations",
* description="API Endpoints of Localizations"
* )
* @OA\Tag(
* name="Access",
* description="API Endpoints of Access"
* )
*
* @OA\Schema(
* schema="Error",
* required={"message"},
* @OA\Property(
* property="message",
* type="string"
* )
* ),
*/


Expand Down
Loading

0 comments on commit 8e14337

Please sign in to comment.