Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API documentation improved and auto generated. #2812

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/Http/Controllers/Admin/JobsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class JobsController extends Controller
{
/**
* List jobs executed on the server and the pending ones.
*
* @param ShowJobsRequest $request
*
* @return PaginatedDataCollection<(int|string),JobHistoryResource>
Expand Down
13 changes: 1 addition & 12 deletions app/Http/Controllers/Admin/Maintenance/FixTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@
class FixTree extends Controller
{
/**
* Clean the path from all files excluding $this->skip.
*
* @return int
*/
public function do(MaintenanceRequest $request): int
{
return Album::query()->fixTree();
}

/**
* Check whether there are files to be removed.
* If not, we will not display the module to reduce complexity.
* Check whether the Album tree is correct.
*
* @return TreeState
*/
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Admin/Maintenance/FullTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
class FullTree extends Controller
{
/**
* Clean the path from all files excluding $this->skip.
* Apply the fix suggested.
* ! This may break the installation. Not our problem.
*
* @return void
*/
Expand All @@ -28,8 +29,7 @@ public function do(FullTreeUpdateRequest $request): void
}

/**
* Check whether there are files to be removed.
* If not, we will not display the module to reduce complexity.
* Display the current full tree of albums.
*
* @return Collection<int,AlbumTree>
*/
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Admin/Maintenance/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class RegisterController extends Controller
{
/**
* Register the Lychee Supporter Edition license key.
*
* @param RegisterRequest $request
*
* @return RegisterData
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
*/
class SettingsController extends Controller
{
/**
* Fetch all the settings available in Lychee.
*
* @param GetAllConfigsRequest $request
*
* @return ConfigCollectionResource
*/
public function getAll(GetAllConfigsRequest $request): ConfigCollectionResource
{
$editable_configs = Configs::query()
Expand All @@ -27,6 +34,13 @@ public function getAll(GetAllConfigsRequest $request): ConfigCollectionResource
return new ConfigCollectionResource($editable_configs);
}

/**
* Set a limited number of configurations with the new values.
*
* @param SetConfigsRequest $request
*
* @return ConfigCollectionResource
*/
public function setConfigs(SetConfigsRequest $request): ConfigCollectionResource
{
$configs = $request->configs();
Expand Down
8 changes: 8 additions & 0 deletions app/Http/Controllers/Admin/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public function __construct(ApplyUpdate $applyUpdate)
$this->applyUpdate = $applyUpdate;
}

/**
* Retrieve Update data from the server.
*
* @param UpdateRequest $request
* @param VersionInfo $versionInfo
*
* @return UpdateInfo
*/
public function get(UpdateRequest $request, VersionInfo $versionInfo): UpdateInfo
{
/** @var VersionChannelType $channelName */
Expand Down
11 changes: 5 additions & 6 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
use Spatie\LaravelData\Data;

/**
* Controller responsible for the authentication of the user.
Expand Down Expand Up @@ -59,17 +58,17 @@ public function logout(): void
/**
* Get the global rights of the current user.
*/
public function getGlobalRights(): Data
public function getGlobalRights(): GlobalRightsResource
{
return new GlobalRightsResource();
}

/**
* First function being called via AJAX.
*
* @return Data
* @return UserResource
*/
public function getCurrentUser(): Data
public function getCurrentUser(): UserResource
{
/** @var User|null $user */
$user = Auth::user();
Expand All @@ -80,9 +79,9 @@ public function getCurrentUser(): Data
/**
* Return the configuration for the authentication.
*
* @return Data
* @return AuthConfig
*/
public function getConfig(): Data
public function getConfig(): AuthConfig
{
return new AuthConfig();
}
Expand Down
43 changes: 43 additions & 0 deletions app/Http/Controllers/Gallery/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public function get(GetAlbumRequest $request): AbstractAlbumResource
return new AbstractAlbumResource($config, $albumResource);
}

/**
* Create an album.
*
* @param AddAlbumRequest $request
*
* @return string
*/
public function createAlbum(AddAlbumRequest $request): string
{
/** @var int $ownerId */
Expand All @@ -92,11 +99,25 @@ public function createAlbum(AddAlbumRequest $request): string
return $create->create($request->title(), $request->parent_album())->id;
}

/**
* Create a tag album.
*
* @param AddTagAlbumRequest $request
*
* @return string
*/
public function createTagAlbum(AddTagAlbumRequest $request, CreateTagAlbum $create): string
{
return $create->create($request->title(), $request->tags())->id;
}

/**
* Update the info of an Album.
*
* @param UpdateAlbumRequest $request
*
* @return EditableBaseAlbumResource
*/
public function updateAlbum(UpdateAlbumRequest $request, SetHeader $setHeader): EditableBaseAlbumResource
{
$album = $request->album();
Expand Down Expand Up @@ -124,6 +145,13 @@ public function updateAlbum(UpdateAlbumRequest $request, SetHeader $setHeader):
return EditableBaseAlbumResource::fromModel($album);
}

/**
* Update the info of a Tag Album.
*
* @param UpdateTagAlbumRequest $request
*
* @return EditableBaseAlbumResource
*/
public function updateTagAlbum(UpdateTagAlbumRequest $request): EditableBaseAlbumResource
{
$album = $request->album();
Expand All @@ -142,6 +170,15 @@ public function updateTagAlbum(UpdateTagAlbumRequest $request): EditableBaseAlbu
return EditableBaseAlbumResource::fromModel($album);
}

/**
* Update the protection policy of an Abstract Album.
*
* @param SetAlbumProtectionPolicyRequest $request
* @param SetProtectionPolicy $setProtectionPolicy
* @param SetSmartProtectionPolicy $setSmartProtectionPolicy
*
* @return AlbumProtectionPolicy
*/
public function updateProtectionPolicy(SetAlbumProtectionPolicyRequest $request,
SetProtectionPolicy $setProtectionPolicy,
SetSmartProtectionPolicy $setSmartProtectionPolicy): AlbumProtectionPolicy
Expand Down Expand Up @@ -224,6 +261,8 @@ public function move(MoveAlbumsRequest $request, Move $move): void
}

/**
* Transfer the ownership of the album to another user.
*
* @param TransferAlbumRequest $request
* @param Transfer $transfer
*
Expand All @@ -235,6 +274,8 @@ public function transfer(TransferAlbumRequest $request, Transfer $transfer): voi
}

/**
* Set the album cover (the square thumb).
*
* @param SetAsCoverRequest $request
*
* @return void
Expand All @@ -247,6 +288,8 @@ public function cover(SetAsCoverRequest $request): void
}

/**
* Set the album header (the hero banner).
*
* @param $request
*
* @return void
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Gallery/AlbumsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class AlbumsController extends Controller
{
/**
* Retrieve all the albums at the root.
*
* @return RootAlbumResource returns the top albums
*/
public function get(Top $top): RootAlbumResource
Expand Down
17 changes: 8 additions & 9 deletions app/Http/Controllers/Gallery/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use App\Http\Resources\GalleryConfigs\PhotoLayoutConfig;
use App\Http\Resources\GalleryConfigs\UploadConfig;
use Illuminate\Routing\Controller;
use Spatie\LaravelData\Data;

/**
* Controller responsible for the config.
Expand All @@ -17,37 +16,37 @@ class ConfigController extends Controller
/**
* Return global gallery config.
*
* @return Data
* @return InitConfig
*/
public function getInit(): Data
public function getInit(): InitConfig
{
return new InitConfig();
}

/**
* Return gallery layout info.
*/
public function getGalleryLayout(): Data
public function getGalleryLayout(): PhotoLayoutConfig
{
return new PhotoLayoutConfig();
}

/**
* Return the configuration of the uploader.
*
* @return Data
* @return UploadConfig
*/
public function getUploadCOnfig(): Data
public function getUploadCOnfig(): UploadConfig
{
return new UploadConfig();
}

/**
* Return global gallery config.
* Return the Footer data.
*
* @return Data
* @return FooterConfig
*/
public function getFooter(): Data
public function getFooter(): FooterConfig
{
return new FooterConfig();
}
Expand Down
12 changes: 8 additions & 4 deletions app/Http/Controllers/Gallery/MapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use App\Http\Resources\Collections\PositionDataResource;
use App\Http\Resources\GalleryConfigs\MapProviderData;
use App\Models\Configs;
use Spatie\LaravelData\Data;

class MapController
{
Expand All @@ -21,19 +20,24 @@ public function __construct()
$this->albumPositionData = resolve(AlbumPositionData::class);
}

public function getProvider(): Data
/**
* Return the configuration data for the Map.
*
* @return MapProviderData
*/
public function getProvider(): MapProviderData
{
return new MapProviderData();
}

/**
* Return an image and the timeout if the frame is supported..
* Return the Map data for an album or root.
*
* @param MapDataRequest $request
*
* @return PositionDataResource
*/
public function getData(MapDataRequest $request): Data
public function getData(MapDataRequest $request): PositionDataResource
{
$album = $request->album();

Expand Down
22 changes: 22 additions & 0 deletions app/Http/Controllers/Gallery/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ class PhotoController extends Controller
{
public const DISK_NAME = 'image-upload';

/**
* Upload a picture.
*
* @param UploadPhotoRequest $request
*
* @return UploadMetaResource
*/
public function upload(UploadPhotoRequest $request): UploadMetaResource
{
$meta = $request->meta();
Expand Down Expand Up @@ -95,6 +102,14 @@ private function process(
return $meta;
}

/**
* Upload a picture from a URL.
*
* @param FromUrlRequest $request
* @param FromUrl $fromUrl
*
* @return string
*/
public function fromUrl(FromUrlRequest $request, FromUrl $fromUrl): string
{
/** @var int $userId */
Expand All @@ -104,6 +119,13 @@ public function fromUrl(FromUrlRequest $request, FromUrl $fromUrl): string
return 'success';
}

/**
* Update the info of a picture.
*
* @param EditPhotoRequest $request
*
* @return PhotoResource
*/
public function update(EditPhotoRequest $request): PhotoResource
{
$photo = $request->photo();
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Gallery/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use App\Models\Photo;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Routing\Controller;
use Spatie\LaravelData\Data;

/**
* Controller responsible for the config.
Expand All @@ -29,7 +28,7 @@ class SearchController extends Controller
*
* @return InitResource
*/
public function init(InitSearchRequest $request): Data
public function init(InitSearchRequest $request): InitResource
{
return new InitResource();
}
Expand Down
Loading
Loading