Fixed api token endpoint documentation

This commit is contained in:
Constantin Graf
2025-02-11 14:44:59 -05:00
committed by Constantin Graf
parent 4ea55e5867
commit 69a8c8bb2b
6 changed files with 38 additions and 13 deletions

View File

@@ -4,13 +4,14 @@ declare(strict_types=1);
namespace App\Http\Resources\V1\ApiToken;
use App\Http\Resources\V1\BaseResource;
use App\Models\Passport\Token;
use Illuminate\Http\Request;
/**
* @property-read Token $resource
*/
class ApiTokenWithAccessTokenResource extends ApiTokenResource
class ApiTokenWithAccessTokenResource extends BaseResource
{
private string $accessToken;
@@ -27,9 +28,21 @@ class ApiTokenWithAccessTokenResource extends ApiTokenResource
*/
public function toArray(Request $request): array
{
$parent = parent::toArray($request);
return $parent + [
return [
/** @var string $id ID of the API token, this ID is NOT a UUID */
'id' => $this->resource->id,
/** @var string $name Name of the API token */
'name' => $this->resource->name,
/** @var bool $revoked Whether the API token is revoked */
'revoked' => $this->resource->revoked,
/** @var array<string> $scopes List of scopes that the API token has */
'scopes' => $this->resource->scopes,
/** @var string $created_at When the API token was created (ISO 8601 format, UTC timezone, example: 2024-02-26T17:17:17Z) */
'created_at' => $this->formatDateTime($this->resource->created_at),
/** @var string|null $expires_at At what time the API token expires (ISO 8601 format, UTC timezone, example: 2024-02-26T17:17:17Z) */
'expires_at' => $this->formatDateTime($this->resource->expires_at),
// Additional fields
/** @var string $access_token Access token that can be used to authenticate requests */
'access_token' => $this->accessToken,
];
}