diff --git a/app/Http/Controllers/Admin/JobsController.php b/app/Http/Controllers/Admin/JobsController.php index 4ebad0b547b..f8bc34a8762 100644 --- a/app/Http/Controllers/Admin/JobsController.php +++ b/app/Http/Controllers/Admin/JobsController.php @@ -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> diff --git a/app/Http/Controllers/Admin/Maintenance/FixTree.php b/app/Http/Controllers/Admin/Maintenance/FixTree.php index b706302540e..8759394551b 100644 --- a/app/Http/Controllers/Admin/Maintenance/FixTree.php +++ b/app/Http/Controllers/Admin/Maintenance/FixTree.php @@ -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 */ diff --git a/app/Http/Controllers/Admin/Maintenance/FullTree.php b/app/Http/Controllers/Admin/Maintenance/FullTree.php index 2d3b444662f..75e38aaa2a3 100644 --- a/app/Http/Controllers/Admin/Maintenance/FullTree.php +++ b/app/Http/Controllers/Admin/Maintenance/FullTree.php @@ -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 */ @@ -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 */ diff --git a/app/Http/Controllers/Admin/Maintenance/RegisterController.php b/app/Http/Controllers/Admin/Maintenance/RegisterController.php index 386d6da1e5f..7bfefd1df64 100644 --- a/app/Http/Controllers/Admin/Maintenance/RegisterController.php +++ b/app/Http/Controllers/Admin/Maintenance/RegisterController.php @@ -11,6 +11,8 @@ class RegisterController extends Controller { /** + * Register the Lychee Supporter Edition license key. + * * @param RegisterRequest $request * * @return RegisterData diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index 2fc962aec9f..03491bf0402 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -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() @@ -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(); diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php index 59d893beb97..b0ac235e56e 100644 --- a/app/Http/Controllers/Admin/UpdateController.php +++ b/app/Http/Controllers/Admin/UpdateController.php @@ -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 */ diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 1ac12365506..2319e0cfb2f 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -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. @@ -59,7 +58,7 @@ public function logout(): void /** * Get the global rights of the current user. */ - public function getGlobalRights(): Data + public function getGlobalRights(): GlobalRightsResource { return new GlobalRightsResource(); } @@ -67,9 +66,9 @@ public function getGlobalRights(): Data /** * 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(); @@ -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(); } diff --git a/app/Http/Controllers/Gallery/AlbumController.php b/app/Http/Controllers/Gallery/AlbumController.php index e9a83a0146e..a7b7ae7c44a 100644 --- a/app/Http/Controllers/Gallery/AlbumController.php +++ b/app/Http/Controllers/Gallery/AlbumController.php @@ -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 */ @@ -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(); @@ -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(); @@ -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 @@ -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 * @@ -235,6 +274,8 @@ public function transfer(TransferAlbumRequest $request, Transfer $transfer): voi } /** + * Set the album cover (the square thumb). + * * @param SetAsCoverRequest $request * * @return void @@ -247,6 +288,8 @@ public function cover(SetAsCoverRequest $request): void } /** + * Set the album header (the hero banner). + * * @param $request * * @return void diff --git a/app/Http/Controllers/Gallery/AlbumsController.php b/app/Http/Controllers/Gallery/AlbumsController.php index 3120124848b..7b0552a7cca 100644 --- a/app/Http/Controllers/Gallery/AlbumsController.php +++ b/app/Http/Controllers/Gallery/AlbumsController.php @@ -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 diff --git a/app/Http/Controllers/Gallery/ConfigController.php b/app/Http/Controllers/Gallery/ConfigController.php index 1d239623275..0eaefb4c827 100644 --- a/app/Http/Controllers/Gallery/ConfigController.php +++ b/app/Http/Controllers/Gallery/ConfigController.php @@ -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. @@ -17,9 +16,9 @@ class ConfigController extends Controller /** * Return global gallery config. * - * @return Data + * @return InitConfig */ - public function getInit(): Data + public function getInit(): InitConfig { return new InitConfig(); } @@ -27,7 +26,7 @@ public function getInit(): Data /** * Return gallery layout info. */ - public function getGalleryLayout(): Data + public function getGalleryLayout(): PhotoLayoutConfig { return new PhotoLayoutConfig(); } @@ -35,19 +34,19 @@ public function getGalleryLayout(): Data /** * 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(); } diff --git a/app/Http/Controllers/Gallery/MapController.php b/app/Http/Controllers/Gallery/MapController.php index 512d426a0dd..0253dcb0e10 100644 --- a/app/Http/Controllers/Gallery/MapController.php +++ b/app/Http/Controllers/Gallery/MapController.php @@ -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 { @@ -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(); diff --git a/app/Http/Controllers/Gallery/PhotoController.php b/app/Http/Controllers/Gallery/PhotoController.php index e3c71fea53a..60887055c64 100644 --- a/app/Http/Controllers/Gallery/PhotoController.php +++ b/app/Http/Controllers/Gallery/PhotoController.php @@ -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(); @@ -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 */ @@ -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(); diff --git a/app/Http/Controllers/Gallery/SearchController.php b/app/Http/Controllers/Gallery/SearchController.php index 88d9aecec3a..55062ef11b4 100644 --- a/app/Http/Controllers/Gallery/SearchController.php +++ b/app/Http/Controllers/Gallery/SearchController.php @@ -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. @@ -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(); } diff --git a/app/Http/Controllers/Gallery/SharingController.php b/app/Http/Controllers/Gallery/SharingController.php index 68590adfe22..a780bd9e8f3 100644 --- a/app/Http/Controllers/Gallery/SharingController.php +++ b/app/Http/Controllers/Gallery/SharingController.php @@ -22,10 +22,12 @@ class SharingController extends Controller { /** + * Create a new Sharing link between a user and an album. + * * @param AddSharingRequest $request * @param Share $share * - * @return array + * @return array */ public function create(AddSharingRequest $request, Share $share): array { diff --git a/app/Http/Controllers/LandingPageController.php b/app/Http/Controllers/LandingPageController.php index 629281b4e2d..6db433c7647 100644 --- a/app/Http/Controllers/LandingPageController.php +++ b/app/Http/Controllers/LandingPageController.php @@ -4,14 +4,13 @@ use App\Http\Resources\GalleryConfigs\LandingPageResource; use Illuminate\Routing\Controller; -use Spatie\LaravelData\Data; /** * Controller responsible for the data displayed on the landing page. */ class LandingPageController extends Controller { - public function __invoke(): Data + public function __invoke(): LandingPageResource { return new LandingPageResource(); } diff --git a/app/Http/Controllers/RSSController.php b/app/Http/Controllers/RSSController.php index 482073df6b1..9c784373d4e 100644 --- a/app/Http/Controllers/RSSController.php +++ b/app/Http/Controllers/RSSController.php @@ -13,6 +13,8 @@ class RSSController extends Controller { /** + * Get the RSS Feed. + * * @param Generate $generate * * @return Collection diff --git a/app/Http/Controllers/StatisticsController.php b/app/Http/Controllers/StatisticsController.php index be3f257cbb7..1e50d07615f 100644 --- a/app/Http/Controllers/StatisticsController.php +++ b/app/Http/Controllers/StatisticsController.php @@ -15,6 +15,8 @@ class StatisticsController extends Controller { /** + * Fetch the used space per user. + * * @param SpacePerUserRequest $request * @param Spaces $spaces * @@ -30,6 +32,8 @@ public function getSpacePerUser(SpacePerUserRequest $request, Spaces $spaces): C } /** + * Fetch the used space per SizeVariant type. + * * @param SpaceSizeVariantRequest $request * @param Spaces $spaces * @@ -48,6 +52,8 @@ public function getSpacePerSizeVariantType(SpaceSizeVariantRequest $request, Spa } /** + * Fetch the used space and number of photos per Album (without descendants). + * * @param SpacePerAlbumRequest $request * @param Spaces $spaces * @@ -72,6 +78,7 @@ public function getSpacePerAlbum(SpacePerAlbumRequest $request, Spaces $spaces): } /** + * Fetch the used space and number of photos per Album with descendants * ! Slow query. * * @param SpacePerAlbumRequest $request diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 22d7a6b3f8f..4254ac9c153 100644 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -15,6 +15,13 @@ */ class UsersController extends Controller { + /** + * Count the number of registered users. + * + * @param UsersRequest $_request + * + * @return int + */ public function count(UsersRequest $_request): int { return User::count(); diff --git a/app/Http/Controllers/VersionController.php b/app/Http/Controllers/VersionController.php index 347072fc2b3..8273d01bc17 100644 --- a/app/Http/Controllers/VersionController.php +++ b/app/Http/Controllers/VersionController.php @@ -4,16 +4,15 @@ use App\Http\Resources\Root\VersionResource; use Illuminate\Routing\Controller; -use Spatie\LaravelData\Data; class VersionController extends Controller { /** * Retrieve the data about updates (so that it is not fully blocking). * - * @return Data + * @return VersionResource */ - public function get(): Data + public function get(): VersionResource { return new VersionResource(); } diff --git a/app/Http/Controllers/WebAuthn/WebAuthnManageController.php b/app/Http/Controllers/WebAuthn/WebAuthnManageController.php index ce2941dbf3f..e71a8902076 100644 --- a/app/Http/Controllers/WebAuthn/WebAuthnManageController.php +++ b/app/Http/Controllers/WebAuthn/WebAuthnManageController.php @@ -30,6 +30,8 @@ public function list(ListCredentialsRequest $request): Collection } /** + * Delete a WebAuthn credential. + * * @throws UnauthenticatedException */ public function delete(DeleteCredentialRequest $request): void diff --git a/app/Http/Resources/OpenApi/DataToResponse.php b/app/Http/Resources/OpenApi/DataToResponse.php new file mode 100644 index 00000000000..9522de9b8da --- /dev/null +++ b/app/Http/Resources/OpenApi/DataToResponse.php @@ -0,0 +1,124 @@ +isInstanceOf(Data::class); + } + + /** + * @param Type $type the type being transformed to schema + */ + public function toSchema(Type $type): ?OpenApiType + { + /** @phpstan-ignore-next-line */ + $reflect = new \ReflectionClass($type->name); + $props = $reflect->getProperties(\ReflectionProperty::IS_PUBLIC); + + $ret = new OpenApiObjectType(); + collect($props)->each(function ($prop) use ($ret) { + $toConvertType = $this->convertReflected($prop->getType()); + $ret->addProperty($prop->name, $this->openApiTransformer->transform($toConvertType)); + }); + + return $ret; + } + + /** + * Set a reference to that object in the return. + * + * @param ObjectType $type + * + * @return Reference + */ + public function reference(ObjectType $type): Reference + { + return new Reference('schemas', $type->name, $this->components); + } + + /** + * Given a pure reflected PHP type, we return the corresponding Scramble type equivalent before Generator conversion. + * + * @return Type + * + * @throws \InvalidArgumentException + * @throws LycheeLogicException + */ + private function convertReflected(\ReflectionNamedType|\ReflectionUnionType|\ReflectionType|null $type): Type + { + if ($type === null) { + return new NullType(); + } + + if ($type instanceof \ReflectionUnionType) { + return $this->handleUnionType($type); + } + + if ($type instanceof \ReflectionIntersectionType) { + throw new LycheeLogicException('Intersection types are not supported.'); + } + + if (!$type instanceof \ReflectionNamedType) { + throw new LycheeLogicException('Unexpected reflection type.'); + } + + $name = $type->getName(); + if ($type->isBuiltin()) { + return $this->handleBuiltin($name); + } + + return match ($name) { + 'Spatie\LaravelData\Data' => throw new LycheeLogicException('Spatie\LaravelData\Data should not be used as return type.'), + 'Illuminate\Support\Collection' => new ArrayType(), // refactor me later. + default => new ObjectType($name), + }; + } + + private function handleUnionType(\ReflectionUnionType $union): Type + { + $types = collect($union->getTypes())->map(fn ($type) => $this->convertReflected($type))->all(); + $unionType = new Union($types); + + return $unionType; + } + + private function handleBuiltin(string $type): Type + { + return match ($type) { + 'null' => new NullType(), + 'int' => new IntegerType(), + 'float' => new FloatType(), + 'bool' => new BooleanType(), + 'array' => new ArrayType(), + 'string' => new StringType(), + default => throw new LycheeLogicException('Unknown type: ' . $type), + }; + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 7d35b243896..1ae4bc06ae8 100644 --- a/composer.json +++ b/composer.json @@ -50,6 +50,7 @@ "ext-tokenizer": "*", "ext-xml": "*", "bepsvpt/secure-headers": "^8.0", + "dedoc/scramble": "^0.11.30", "doctrine/dbal": "^3.1", "geocoder-php/cache-provider": "^4.3", "geocoder-php/nominatim-provider": "^5.5", diff --git a/composer.lock b/composer.lock index b8f7af64129..7e9e0b2f628 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3ce0219be0ac8430114dab3f0dacbd00", + "content-hash": "218112bf927607113295b5a4501aef91", "packages": [ { "name": "amphp/amp", @@ -1334,6 +1334,81 @@ }, "time": "2024-04-12T12:12:48+00:00" }, + { + "name": "dedoc/scramble", + "version": "v0.11.30", + "source": { + "type": "git", + "url": "https://github.com/dedoc/scramble.git", + "reference": "43d8f7573e83d8dbf080bc76a9f11cfd0318ad74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dedoc/scramble/zipball/43d8f7573e83d8dbf080bc76a9f11cfd0318ad74", + "reference": "43d8f7573e83d8dbf080bc76a9f11cfd0318ad74", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^10.0|^11.0", + "myclabs/deep-copy": "^1.12", + "nikic/php-parser": "^5.0", + "php": "^8.1", + "phpstan/phpdoc-parser": "^1.0|^2.0", + "spatie/laravel-package-tools": "^1.9.2" + }, + "require-dev": { + "laravel/pint": "^v1.1.0", + "nunomaduro/collision": "^7.0|^8.0", + "orchestra/testbench": "^8.0|^9.0", + "pestphp/pest": "^2.34", + "pestphp/pest-plugin-laravel": "^2.3", + "phpunit/phpunit": "^10.5", + "spatie/pest-plugin-snapshots": "^2.1" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Dedoc\\Scramble\\ScrambleServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Dedoc\\Scramble\\": "src", + "Dedoc\\Scramble\\Database\\Factories\\": "database/factories" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Lytvynenko", + "email": "litvinenko95@gmail.com", + "role": "Developer" + } + ], + "description": "Automatic generation of API documentation for Laravel applications.", + "homepage": "https://github.com/dedoc/scramble", + "keywords": [ + "documentation", + "laravel", + "openapi" + ], + "support": { + "issues": "https://github.com/dedoc/scramble/issues", + "source": "https://github.com/dedoc/scramble/tree/v0.11.30" + }, + "funding": [ + { + "url": "https://github.com/romalytvynenko", + "type": "github" + } + ], + "time": "2024-12-05T11:24:58+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -5214,6 +5289,66 @@ }, "time": "2024-09-04T18:46:31+00:00" }, + { + "name": "myclabs/deep-copy", + "version": "1.12.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2024-11-08T17:47:46+00:00" + }, { "name": "nesbot/carbon", "version": "3.8.2", @@ -13286,66 +13421,6 @@ }, "time": "2024-05-16T03:13:13+00:00" }, - { - "name": "myclabs/deep-copy", - "version": "1.12.1", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", - "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "conflict": { - "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3 <3.2.2" - }, - "require-dev": { - "doctrine/collections": "^1.6.8", - "doctrine/common": "^2.13.3 || ^3.2.2", - "phpspec/prophecy": "^1.10", - "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" - }, - "type": "library", - "autoload": { - "files": [ - "src/DeepCopy/deep_copy.php" - ], - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" - }, - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", - "type": "tidelift" - } - ], - "time": "2024-11-08T17:47:46+00:00" - }, { "name": "nunomaduro/collision", "version": "v8.5.0", diff --git a/config/scramble.php b/config/scramble.php new file mode 100644 index 00000000000..34d6074ab40 --- /dev/null +++ b/config/scramble.php @@ -0,0 +1,89 @@ + 'api/v2', + + /* + * Your API domain. By default, app domain is used. This is also a part of the default API routes + * matcher, so when implementing your own, make sure you use this config if needed. + */ + 'api_domain' => null, + + /* + * The path where your OpenAPI specification will be exported. + */ + 'export_path' => 'api.json', + + 'info' => [ + /* + * API version. + */ + 'version' => env('API_VERSION', '2.0.0'), + + /* + * Description rendered on the home page of the API documentation (`/docs/api`). + */ + 'description' => '', + ], + + /* + * Customize Stoplight Elements UI + */ + 'ui' => [ + /* + * Define the title of the documentation's website. App name is used when this config is `null`. + */ + 'title' => null, + + /* + * Define the theme of the documentation. Available options are `light` and `dark`. + */ + 'theme' => 'light', + + /* + * Hide the `Try It` feature. Enabled by default. + */ + 'hide_try_it' => false, + + /* + * URL to an image that displays as a small square logo next to the title, above the table of contents. + */ + 'logo' => '', + + /* + * Use to fetch the credential policy for the Try It feature. Options are: omit, include (default), and same-origin + */ + 'try_it_credentials_policy' => 'include', + ], + + /* + * The list of servers of the API. By default, when `null`, server URL will be created from + * `scramble.api_path` and `scramble.api_domain` config variables. When providing an array, you + * will need to specify the local server URL manually (if needed). + * + * Example of non-default config (final URLs are generated using Laravel `url` helper): + * + * ```php + * 'servers' => [ + * 'Live' => 'api', + * 'Prod' => 'https://scramble.dedoc.co/api', + * ], + * ``` + */ + 'servers' => null, + + 'middleware' => [ + 'web', + // RestrictedDocsAccess::class, + ], + + 'extensions' => [ + DataToResponse::class, + ], +]; diff --git a/routes/api_v2.php b/routes/api_v2.php index b80336d734e..24daa636145 100644 --- a/routes/api_v2.php +++ b/routes/api_v2.php @@ -201,7 +201,6 @@ Route::get('/Maintenance::jobs', [Admin\Maintenance\FixJobs::class, 'check']); Route::post('/Maintenance::jobs', [Admin\Maintenance\FixJobs::class, 'do']); Route::get('/Maintenance::tree', [Admin\Maintenance\FixTree::class, 'check']); -Route::post('/Maintenance::tree', [Admin\Maintenance\FixTree::class, 'do']); Route::get('/Maintenance::genSizeVariants', [Admin\Maintenance\GenSizeVariants::class, 'check']); Route::post('/Maintenance::genSizeVariants', [Admin\Maintenance\GenSizeVariants::class, 'do']); Route::get('/Maintenance::missingFileSize', [Admin\Maintenance\MissingFileSizes::class, 'check']); diff --git a/tests/Feature_v2/Maintenance/TreeTest.php b/tests/Feature_v2/Maintenance/TreeTest.php index a14b7834194..7441305fca0 100644 --- a/tests/Feature_v2/Maintenance/TreeTest.php +++ b/tests/Feature_v2/Maintenance/TreeTest.php @@ -20,26 +20,17 @@ public function testGuest(): void { $response = $this->getJsonWithData('Maintenance::tree', []); $this->assertUnauthorized($response); - - $response = $this->postJson('Maintenance::tree'); - $this->assertUnauthorized($response); } public function testUser(): void { $response = $this->actingAs($this->userLocked)->getJsonWithData('Maintenance::tree'); $this->assertForbidden($response); - - $response = $this->actingAs($this->userLocked)->postJson('Maintenance::tree'); - $this->assertForbidden($response); } public function testAdmin(): void { $response = $this->actingAs($this->admin)->getJsonWithData('Maintenance::tree'); $this->assertOk($response); - - $response = $this->actingAs($this->admin)->postJson('Maintenance::tree'); - $this->assertOk($response); } } \ No newline at end of file