From 9c993e4686b7b34a5cde346bb06abae7fab331da Mon Sep 17 00:00:00 2001 From: "H. C. Kruse" Date: Fri, 3 May 2024 19:29:52 +0200 Subject: [PATCH] refactor: Update swagger documentation --- .../Api/V2/AbstractApiV2Controller.php | 10 ++---- .../V2/Rsi/CommLink/CommLinkController.php | 7 ++-- .../Rsi/CommLink/CommLinkSearchController.php | 35 ++++++++----------- .../Api/V2/SC/Char/ArmorController.php | 8 ++--- .../Api/V2/SC/Char/ClothesController.php | 7 +--- .../PersonalWeaponController.php | 5 +-- .../WeaponAttachmentController.php | 9 ++--- .../Api/V2/SC/FactionController.php | 5 +-- .../Controllers/Api/V2/SC/FoodController.php | 9 ++--- .../Controllers/Api/V2/SC/ItemController.php | 8 +---- .../Api/V2/SC/ManufacturerController.php | 11 +++--- .../Api/V2/SC/MissionController.php | 9 ++--- .../Api/V2/SC/MissionGiverController.php | 5 +-- .../Controllers/Api/V2/SC/ShopController.php | 9 ++--- .../V2/SC/Vehicle/VehicleItemController.php | 9 ++--- .../V2/SC/Vehicle/VehicleWeaponController.php | 9 ++--- .../V2/StarCitizen/GalactapediaController.php | 10 +++--- .../Api/V2/StarCitizen/StatController.php | 8 ++--- 18 files changed, 61 insertions(+), 112 deletions(-) diff --git a/app/Http/Controllers/Api/V2/AbstractApiV2Controller.php b/app/Http/Controllers/Api/V2/AbstractApiV2Controller.php index 37ec47ff6..df583a982 100644 --- a/app/Http/Controllers/Api/V2/AbstractApiV2Controller.php +++ b/app/Http/Controllers/Api/V2/AbstractApiV2Controller.php @@ -81,6 +81,7 @@ enum: [ enum: [ 'shops', 'shops.items', + 'variants', ] ), ), @@ -138,7 +139,7 @@ abstract class AbstractApiV2Controller extends Controller /** * AbstractApiController constructor. * - * @param Request $request API Request + * @param Request $request API Request */ public function __construct(Request $request) { @@ -184,15 +185,13 @@ private function processLimit(): void */ private function processLocale(): void { - if ($this->request->has(self::LOCALE) && null !== $this->request->get(self::LOCALE, null)) { + if ($this->request->has(self::LOCALE) && $this->request->get(self::LOCALE, null) !== null) { $this->setLocale($this->request->get(self::LOCALE)); } } /** * Set the Locale - * - * @param string $localeCode */ protected function setLocale(string $localeCode): void { @@ -204,9 +203,6 @@ protected function setLocale(string $localeCode): void /** * Cleans the name for query use - * - * @param string $name - * @return string */ protected function cleanQueryName(string $name): string { diff --git a/app/Http/Controllers/Api/V2/Rsi/CommLink/CommLinkController.php b/app/Http/Controllers/Api/V2/Rsi/CommLink/CommLinkController.php index e185f1b30..afc300b73 100644 --- a/app/Http/Controllers/Api/V2/Rsi/CommLink/CommLinkController.php +++ b/app/Http/Controllers/Api/V2/Rsi/CommLink/CommLinkController.php @@ -57,7 +57,7 @@ class CommLinkController extends AbstractApiV2Controller type: 'array', items: new OA\Items(ref: '#/components/schemas/comm_link_v2') ) - ) + ), ] )] public function index(): AnonymousResourceCollection @@ -98,11 +98,14 @@ public function index(): AnonymousResourceCollection ref: '#/components/schemas/comm_link_v2', response: 200, description: 'A singular Comm-Link', + content: new OA\JsonContent( + ref: '#/components/schemas/item_link_v2' + ) ), new OA\Response( response: 404, description: 'No Comm-Link with specified ID found.', - ) + ), ] )] public function show(Request $request): AbstractBaseResource diff --git a/app/Http/Controllers/Api/V2/Rsi/CommLink/CommLinkSearchController.php b/app/Http/Controllers/Api/V2/Rsi/CommLink/CommLinkSearchController.php index d1b79e587..4472411b2 100644 --- a/app/Http/Controllers/Api/V2/Rsi/CommLink/CommLinkSearchController.php +++ b/app/Http/Controllers/Api/V2/Rsi/CommLink/CommLinkSearchController.php @@ -42,7 +42,7 @@ class CommLinkSearchController extends AbstractApiV2Controller type: 'object', ), example: '{"query": "Banu Merchantman"}', - ) + ), ] ), tags: ['Comm-Links', 'RSI-Website'], @@ -51,14 +51,14 @@ class CommLinkSearchController extends AbstractApiV2Controller ], responses: [ new OA\Response( - ref: '#/components/schemas/comm_link_v2', response: 200, description: 'A singular Comm-Link', + content: new OA\JsonContent(ref: '#/components/schemas/comm_link_v2') ), new OA\Response( response: 404, description: 'No Comm-Link with found.', - ) + ), ], )] public function searchByTitle(Request $request): AnonymousResourceCollection @@ -94,7 +94,7 @@ public function searchByTitle(Request $request): AnonymousResourceCollection type: 'object', ), example: '{"url": "https://robertsspaceindustries.com/i/cc75a45005a236c6e015dfc2782a2f55ed1e84a2/ADdPNihJzmPbNuTnFsH1DqUeqBRpXdSXVVtgJTyDDgscGKrzJuoFjResiiucPBBDeyrBscqRyZz4qxNsSbWvqUwdG/alien-week-2022-front.webp"}', - ) + ), ] ), tags: ['Comm-Links', 'RSI-Website'], @@ -110,7 +110,7 @@ public function searchByTitle(Request $request): AnonymousResourceCollection new OA\Response( response: 404, description: 'No Comm-Link found.', - ) + ), ], )] public function reverseImageLinkSearch(Request $request): AnonymousResourceCollection @@ -129,7 +129,7 @@ public function reverseImageLinkSearch(Request $request): AnonymousResourceColle array_pop($parts); $path = implode('/', $parts); - $image->where('src', 'LIKE', $path . '%'); + $image->where('src', 'LIKE', $path.'%'); } else { $image->where('dir', $dir); } @@ -190,7 +190,7 @@ enum: [ ), ), explode: false, - ) + ), ], responses: [ new OA\Response( @@ -204,7 +204,7 @@ enum: [ new OA\Response( response: 404, description: 'No Comm-Link found.', - ) + ), ], )] public function reverseImageSearch(Request $request): AnonymousResourceCollection @@ -230,7 +230,7 @@ public function reverseImageSearch(Request $request): AnonymousResourceCollectio 'pdq_hash4' => $pdqHash[3], ]; - $data = $this->getResultImages($hashData, (int)$request->get('similarity')); + $data = $this->getResultImages($hashData, (int) $request->get('similarity')); return ImageHashResource::collection($data); } @@ -268,7 +268,7 @@ function (object $data) { $image->similarity_method = __('Basierend auf Merkmalen des Inhalts'); } else { $image->similarity = round((1 - ($data->pdq_distance / 256)) * 100); - $image->similarity_method = ''; #PDQ + $image->similarity_method = ''; //PDQ } $image->pdq_distance = $data->pdq_distance ?? $image->p_distance; @@ -284,8 +284,7 @@ function (object $data) { /** * Returns the RSI directory hash of an image url * - * @param string $url The RSI Media URl - * + * @param string $url The RSI Media URl * @return string The directory hash of the image */ private function getDirHashFromImageUrl(string $url): string @@ -305,7 +304,7 @@ private function getDirHashFromImageUrl(string $url): string */ private function checkExtensionsLoaded(): void { - if (!extension_loaded('gd') && !extension_loaded('imagick')) { + if (! extension_loaded('gd') && ! extension_loaded('imagick')) { app('Log')::error('Required extension "GD" or "Imagick" not available.'); throw new HttpException(501, 'Required extension "GD" or "Imagick" not available.'); @@ -315,7 +314,6 @@ private function checkExtensionsLoaded(): void /** * Return hashes based on database connection type * - * @param array $hashData * * @return Builder[]|Collection|\Illuminate\Support\Collection */ @@ -332,8 +330,7 @@ private function getHashesFromDatabase(array $hashData) /** * Get the image hashes that equal the provided hash * - * @param string $hash The image hash - * + * @param string $hash The image hash * @return Builder[]|Collection */ private function getHashesFromSQLiteStore(string $hash) @@ -346,9 +343,7 @@ private function getHashesFromSQLiteStore(string $hash) /** * Get the image hashes matching the provided hash method and hamming distance * - * @param array $hashes Image hash split in the middle and hex decoded - * - * @return \Illuminate\Support\Collection + * @param array $hashes Image hash split in the middle and hex decoded */ private function getHashesFromSQLStore(array $hashes): \Illuminate\Support\Collection { @@ -356,7 +351,7 @@ private function getHashesFromSQLStore(array $hashes): \Illuminate\Support\Colle ->with('image') ->select('comm_link_image_hashes.comm_link_image_id') ->selectRaw( - <<