From e4b446ed6a4779f7f0ed4ca824eb51eeec7acd4b Mon Sep 17 00:00:00 2001 From: Ariyutta Date: Tue, 29 Sep 2026 17:17:00 +0700 Subject: [PATCH] Penambahan Docs API Verifikator Absen --- .env | 2 + .env.example | 3 + .../TriDharma/MengajarController.php | 5 +- .../Api/Presensi/PengajuanAbsenController.php | 39 ++- app/Http/Middleware/DocsToken.php | 59 ++++ app/Providers/AppServiceProvider.php | 21 ++ app/Services/PoinService.php | 4 +- app/Support/ApiDocsSummaries.php | 73 ++++ composer.json | 1 + composer.lock | 311 ++++++++++++++---- config/scramble.php | 191 +++++++++++ .../views/errors/docs-unauthorized.blade.php | 24 ++ .../views/vendor/scramble/docs.blade.php | 234 +++++++++++++ 13 files changed, 892 insertions(+), 75 deletions(-) create mode 100644 app/Http/Middleware/DocsToken.php create mode 100644 app/Support/ApiDocsSummaries.php create mode 100644 config/scramble.php create mode 100644 resources/views/errors/docs-unauthorized.blade.php create mode 100644 resources/views/vendor/scramble/docs.blade.php diff --git a/.env b/.env index 75a5d8cb..589225a7 100644 --- a/.env +++ b/.env @@ -93,3 +93,5 @@ GOOGLE_DRIVE_FOLDER_ID=0AJQK-NMrB4b_Uk9PVA # 1 = Login biasa (NIP/Password + Google OAuth) # 2 = Login SSO Portal Untan (khusus domain *.untan.ac.id) LOGIN_MODE=2 + +DOCS_TOKEN=3863b2e41c487d57f6a14d8a068eb817f244374bed7a9e3d diff --git a/.env.example b/.env.example index fcb585c0..5c6c9dad 100644 --- a/.env.example +++ b/.env.example @@ -93,3 +93,6 @@ GOOGLE_DRIVE_FOLDER_ID= # 1 = Login Biasa (NIP/Password + Google OAuth) # 2 = Login SSO Portal Untan (khusus domain *.untan.ac.id) LOGIN_MODE=2 + +# Token akses halaman dokumentasi API (/docs) +DOCS_TOKEN= diff --git a/app/Http/Controllers/Api/Pengajuan/TriDharma/MengajarController.php b/app/Http/Controllers/Api/Pengajuan/TriDharma/MengajarController.php index 31558b12..7dd38e79 100644 --- a/app/Http/Controllers/Api/Pengajuan/TriDharma/MengajarController.php +++ b/app/Http/Controllers/Api/Pengajuan/TriDharma/MengajarController.php @@ -22,9 +22,9 @@ class MengajarController extends Controller $exceptions = [196312201988101001, 196106051986022001]; $start = Carbon::parse('2024-05-20 00:00:00'); $end = Carbon::parse('2024-06-15 23:59:59'); - $user = Pegawai::select('id', 'nip', 'nama', 'jenis_pegawai')->where('nip', $request->nip)->orWhere('nip_siakad', $request->nip)->firstOrFail(); + $user = Pegawai::select('id', 'nip', 'nama', 'jenis_pegawai')->where('nip', $request->nip)->orWhere('nip_siakad', $request->nip)->first(); - if (!in_array($user->nip, $exceptions)) { + if (!in_array($user?->nip, $exceptions)) { if (!now()->isBetween($start, $end)) { return response()->json([ 'code' => 400, @@ -33,6 +33,7 @@ class MengajarController extends Controller ], 400); } } + abort_if(!$user, 404, 'Pegawai tidak ditemukan'); try { if ($user->jenis_pegawai === 'dosen') { $token = $request->bearerToken(); diff --git a/app/Http/Controllers/Api/Presensi/PengajuanAbsenController.php b/app/Http/Controllers/Api/Presensi/PengajuanAbsenController.php index 929576c9..f1de4a38 100644 --- a/app/Http/Controllers/Api/Presensi/PengajuanAbsenController.php +++ b/app/Http/Controllers/Api/Presensi/PengajuanAbsenController.php @@ -37,12 +37,14 @@ class PengajuanAbsenController extends Controller $bulan--; } - $pegawais = Honorer::with('unit:id,nama') + $filterAbsen = function ($query) use ($periode, $bulan) { + $query->where('periode', $periode) + ->whereMonth('tanggal_mulai', $bulan); + }; + + $honorers = Honorer::with('unit:id,nama') ->select('nip', 'nama', 'unit_id') - ->with(['absen' => function ($query) use ($periode, $bulan) { - $query->where('periode', $periode) - ->whereMonth('tanggal_mulai', $bulan); - }]) + ->with(['absen' => $filterAbsen]) ->get() ->map(function ($pegawai) { $absen = $pegawai->absen; @@ -52,13 +54,30 @@ class PengajuanAbsenController extends Controller }); return $pegawai; - }) + }); + + $tendiks = Tendik::select('nip', 'nama', 'unit_kerja_id', 'unit_kerja_nama') + ->whereHas('absen', $filterAbsen) + ->with(['absen' => $filterAbsen]) + ->get() + ->map(function ($pegawai) { + $absen = $pegawai->absen; + $unit = ['id' => $pegawai->unit_kerja_id, 'nama' => $pegawai->unit_kerja_nama]; + unset($pegawai->absen, $pegawai->unit_kerja_id, $pegawai->unit_kerja_nama); + $pegawai->unit = $unit; + $pegawai->absen = $absen->countBy(function ($absen) { + return $absen->status; + }); + + return $pegawai; + }); + + return $honorers + ->concat($tendiks) ->filter(function ($pegawai) { return $pegawai->absen->count(); }) - ->flatten(1); - - return $pegawais; + ->values(); } public function show(Request $request, string $nip) @@ -488,7 +507,7 @@ class PengajuanAbsenController extends Controller } return response()->json([ - 'code' => 400, + 'code' => 200, 'status' => false, 'message' => 'Pengajuan absen tidak ditemukan', ]); diff --git a/app/Http/Middleware/DocsToken.php b/app/Http/Middleware/DocsToken.php new file mode 100644 index 00000000..98bb324a --- /dev/null +++ b/app/Http/Middleware/DocsToken.php @@ -0,0 +1,59 @@ +", header "X-Docs-Token", + * atau query "?token=". Setelah valid lewat query, dibuat cookie (berisi hash token) + * supaya request lanjutan dari halaman (mis. /docs/api.json) tetap lolos. + */ +class DocsToken +{ + private const COOKIE = 'docs_access'; + + public function handle(Request $request, Closure $next): Response + { + $expected = (string) config('scramble.docs_token'); + + if ($expected === '') { + return $this->deny('DOCS_TOKEN belum dikonfigurasi.', 403); + } + + $provided = $request->bearerToken() + ?: $request->header('X-Docs-Token') + ?: $request->query('token'); + + if (is_string($provided) && $provided !== '' && hash_equals($expected, $provided)) { + $response = $next($request); + + return $response->withCookie(cookie( + self::COOKIE, hash('sha256', $expected), 60 * 8, '/docs', null, $request->isSecure(), true, false, 'lax' + )); + } + + // Token yang dikirim tapi salah selalu ditolak, walau cookie lama masih valid. + if (is_string($provided) && $provided !== '') { + return $this->deny('Token dokumentasi tidak valid.', 401) + ->withCookie(cookie()->forget(self::COOKIE, '/docs')); + } + + $cookie = $request->cookies->get(self::COOKIE); + + if (is_string($cookie) && hash_equals(hash('sha256', $expected), $cookie)) { + return $next($request); + } + + return $this->deny('Token dokumentasi tidak valid atau belum disertakan.', 401); + } + + private function deny(string $message, int $status): Response + { + return response()->view('errors.docs-unauthorized', ['message' => $message], $status); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b163f5ac..d37c11a5 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,8 +2,13 @@ namespace App\Providers; +use App\Support\ApiDocsSummaries; +use Dedoc\Scramble\Scramble; use Illuminate\Database\Eloquent\Relations\Relation; +use Illuminate\Routing\Route; +use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Str; class AppServiceProvider extends ServiceProvider { @@ -20,6 +25,22 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { + Scramble::configure()->expose( + ui: fn (Router $router, $action) => $router->get('docs', $action)->name('scramble.docs.ui'), + document: fn (Router $router, $action) => $router->get('docs/api.json', $action)->name('scramble.docs.document'), + ); + + Scramble::afterOpenApiGenerated(new ApiDocsSummaries); + + // Batasi endpoint yang tampil di /docs lewat config('scramble.visible_routes'). + $defaultRoutes = Scramble::configure()->routes(); + Scramble::routes(function (Route $route) use ($defaultRoutes) { + $visible = config('scramble.visible_routes', []); + + return $defaultRoutes($route) + && ($visible === [] || Str::is($visible, $route->uri())); + }); + Relation::morphMap([ 'App\Models\Syarat' => 'App\Models\DokSiremun\Syarat', 'App\Models\Mengajar' => 'App\Models\DokSiremun\Mengajar', diff --git a/app/Services/PoinService.php b/app/Services/PoinService.php index 4ee7fe43..2a72b9eb 100644 --- a/app/Services/PoinService.php +++ b/app/Services/PoinService.php @@ -98,9 +98,9 @@ class PoinService } if ($periode === 383) { - $rawQuery = '(poin_total / sks) as poin_per_sks'; + $rawQuery = '(poin_total / CASE WHEN sks = 0 THEN 1 ELSE sks END) as poin_per_sks'; } else { - $rawQuery = '(poin_total / beban_mengajar) as poin_per_sks'; + $rawQuery = '(poin_total / CASE WHEN beban_mengajar = 0 THEN 1 ELSE beban_mengajar END) as poin_per_sks'; } $mengajars = $this->triDharmaService->mengajarSiakad($nip, $periode, 6, 8, $column, $rawQuery, $jenjang, $tipeMk)->sortByDesc('poin_per_sks'); diff --git a/app/Support/ApiDocsSummaries.php b/app/Support/ApiDocsSummaries.php new file mode 100644 index 00000000..fc9b84de --- /dev/null +++ b/app/Support/ApiDocsSummaries.php @@ -0,0 +1,73 @@ + " sesuai route. Endpoint yang docblock-nya sudah punya + * summary tidak ditimpa; tambahkan endpoint baru di sini agar punya nama yang rapi. + */ +class ApiDocsSummaries +{ + private const SUMMARIES = [ + 'get /v1/rubrik' => 'Daftar Rubrik', + 'get /v1/rubrik/{id}' => 'Detail Rubrik', + + 'get /v1/jabatan/{nip}' => 'Jabatan Pegawai', + 'get /v1/jabatan/fungsional' => 'Daftar Jabatan Fungsional', + 'get /v1/jabatan/tugas-tambahan' => 'Daftar Jabatan Tugas Tambahan', + + 'get /v1/pengajuan-absen' => 'Daftar Pengajuan Absen', + 'get /v1/pengajuan-absen/{nip}' => 'Pengajuan Absen Pegawai', + 'post /v1/pengajuan-absen' => 'Buat Pengajuan Absen', + 'post /v1/pengajuan-absen/exists' => 'Duplikasi Pengajuan Absen', + 'delete /v1/pengajuan-absen/delete/{id}' => 'Hapus Pengajuan Absen', + 'patch /v1/pengajuan-absen/batalkan/{id}' => 'Batalkan Pengajuan Absen', + + 'get /v1/poin/{nip}' => 'Poin Pegawai', + + 'get /v1/pegawai' => 'Daftar Pegawai', + 'get /v1/pegawai/{nip}' => 'Detail Pegawai', + + 'get /v1/laporan-kegiatan/kompetisi' => 'Laporan Kegiatan Kompetisi', + 'get /v1/laporan-kegiatan/mbkm' => 'Laporan Kegiatan MBKM', + + 'get /v1/pengajuan/sanggahan/{nip}' => 'Daftar Sanggahan', + 'post /v1/pengajuan/sanggahan' => 'Kirim Sanggahan', + 'get /v1/pengajuan/tri-dharma/mengajar' => 'Pengajuan Mengajar', + 'get /v1/pengajuan/tri-dharma/menguji' => 'Pengajuan Menguji', + 'get /v1/pengajuan/tri-dharma/membimbing' => 'Pengajuan Membimbing', + 'get /v1/pengajuan/mbkm' => 'Pengajuan MBKM', + 'get /v1/pengajuan/modul' => 'Pengajuan Modul', + + 'get /v1/verifikator/presensi/honorer/{unit}' => 'Presensi Honorer per Unit', + 'get /v1/verifikator/presensi/{unit}' => 'Presensi per Unit', + 'get /v1/verifikator/presensi/{unit}/{nip}' => 'Detail Presensi Pegawai', + 'get /v1/verifikator/presensi/{nip}/{nip}' => 'Detail Presensi Pegawai', + + 'get /v1/remunerasi/{nip}' => 'Remunerasi Pegawai', + 'get /v1/remunerasi/poin' => 'Poin Remunerasi', + 'get /v1/remunerasi/skp' => 'Data SKP', + + 'post /v1/verifikasi-absen/link' => 'Buat Link Verifikasi', + 'get /v1/verifikasi-absen/{id}' => 'Detail Verifikasi Absen', + 'post /v1/verifikasi-absen/{id}/setujui' => 'Setujui Pengajuan Absen', + 'post /v1/verifikasi-absen/{id}/tolak' => 'Tolak Pengajuan Absen', + ]; + + public function __invoke(OpenApi $openApi): void + { + foreach ($openApi->paths as $path) { + foreach ($path->operations as $operation) { + $key = strtolower($operation->method).' /'.ltrim($path->path, '/'); + + if ($operation->summary === '' && isset(self::SUMMARIES[$key])) { + $operation->summary(self::SUMMARIES[$key]); + } + } + } + } +} diff --git a/composer.json b/composer.json index 2b6426ac..46900912 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "license": "MIT", "require": { "php": "^8.2", + "dedoc/scramble": "^0.13.45", "google/apiclient": "^2.19", "laravel/framework": "^12.0", "laravel/socialite": "^5.23", diff --git a/composer.lock b/composer.lock index 6b5034ff..cdb29b84 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": "ff4de989ae1021516a8c7e527a1faed3", + "content-hash": "10d90e96a4aad7de117b9533d45d6150", "packages": [ { "name": "brick/math", @@ -291,6 +291,87 @@ ], "time": "2025-08-20T19:15:30+00:00" }, + { + "name": "dedoc/scramble", + "version": "v0.13.45", + "source": { + "type": "git", + "url": "https://github.com/dedoc/scramble.git", + "reference": "4f096c49d555c580d7ce7a978896bb3d8b28dc4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dedoc/scramble/zipball/4f096c49d555c580d7ce7a978896bb3d8b28dc4d", + "reference": "4f096c49d555c580d7ce7a978896bb3d8b28dc4d", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^10.0|^11.0|^12.0|^13.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": { + "larastan/larastan": "^3.3", + "laravel/pint": "^v1.1.0", + "laravel/scout": "^10.0|^11.0", + "nunomaduro/collision": "^7.0|^8.0", + "orchestra/testbench": "^8.0|^9.0|^10.0|^11.0", + "pestphp/pest": "^2.34|^3.7|^4.4", + "pestphp/pest-plugin-laravel": "^2.3|^3.1|^4.1", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.5|^11.5.3|^12.5.12", + "spatie/laravel-permission": "^6.10|^7.2", + "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.13.45" + }, + "funding": [ + { + "url": "https://github.com/romalytvynenko", + "type": "github" + } + ], + "time": "2026-09-18T15:47:56+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -3221,6 +3302,66 @@ ], "time": "2026-01-02T08:56:05+00:00" }, + { + "name": "myclabs/deep-copy", + "version": "1.13.4", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "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.13.4" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2025-08-01T08:46:24+00:00" + }, { "name": "nesbot/carbon", "version": "3.11.4", @@ -4041,6 +4182,53 @@ ], "time": "2026-04-10T01:33:53+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "2.3.6", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "1427af4647235b4a73b13940b1f1258d3584f36e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/1427af4647235b4a73b13940b1f1258d3584f36e", + "reference": "1427af4647235b4a73b13940b1f1258d3584f36e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^5.3.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.6" + }, + "time": "2026-09-27T20:07:45+00:00" + }, { "name": "psr/cache", "version": "3.0.0", @@ -4779,6 +4967,67 @@ }, "time": "2025-12-14T04:43:48+00:00" }, + { + "name": "spatie/laravel-package-tools", + "version": "1.93.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-package-tools.git", + "reference": "7aeef26bd8d4909bec744dbf47aee7d1395588c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/7aeef26bd8d4909bec744dbf47aee7d1395588c1", + "reference": "7aeef26bd8d4909bec744dbf47aee7d1395588c1", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^10.0|^11.0|^12.0|^13.0", + "php": "^8.1" + }, + "require-dev": { + "mockery/mockery": "^1.5", + "orchestra/testbench": "^8.0|^9.2|^10.0|^11.0", + "pestphp/pest": "^2.1|^3.1|^4.0", + "phpunit/php-code-coverage": "^10.0|^11.0|^12.0", + "phpunit/phpunit": "^10.5|^11.5|^12.5", + "spatie/pest-plugin-test-time": "^2.2|^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\LaravelPackageTools\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Tools for creating Laravel packages", + "homepage": "https://github.com/spatie/laravel-package-tools", + "keywords": [ + "laravel-package-tools", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-package-tools/issues", + "source": "https://github.com/spatie/laravel-package-tools/tree/1.93.3" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2026-09-28T07:16:50+00:00" + }, { "name": "spatie/laravel-permission", "version": "6.25.0", @@ -8338,66 +8587,6 @@ }, "time": "2024-05-16T03:13:13+00:00" }, - { - "name": "myclabs/deep-copy", - "version": "1.13.4", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", - "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", - "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.13.4" - }, - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", - "type": "tidelift" - } - ], - "time": "2025-08-01T08:46:24+00:00" - }, { "name": "nunomaduro/collision", "version": "v8.9.4", diff --git a/config/scramble.php b/config/scramble.php new file mode 100644 index 00000000..0b495ecc --- /dev/null +++ b/config/scramble.php @@ -0,0 +1,191 @@ + [ + * 'include' => 'api', + * 'exclude' => ['api/internal'], + * ], + * + * Without *, patterns match path segments (api matches api and api/users, not apiary). + * With *, Str::is is used (e.g. api/v*). + * + * One static include → default server is /{include} and paths are stripped (/users). + * Multiple includes or wildcards → server defaults to / and paths stay full (/api/users). + * Override with `servers`, or use Scramble::registerApi() for separate bases. + */ + 'api_path' => 'api', + + /* + * 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', + + /* + * Cache configuration for the generated OpenAPI document. + * + * Use `scramble:cache` to warm the cache and `scramble:clear` to invalidate it. + */ + 'cache' => [ + 'key' => 'scramble.openapi', + 'store' => 'file', + ], + + 'info' => [ + /* + * API version. + */ + 'version' => env('API_VERSION', '0.0.1'), + + /* + * Description rendered on the home page of the API documentation (`/docs/api`). + */ + 'description' => 'Dokumentasi API Verifikator UNTAN.', + ], + + 'ui' => [ + 'title' => null, + ], + + /* + * Load Scramble's development tools on documentation pages. An explicit + * SCRAMBLE_DEV_TOOLS value takes precedence over APP_DEBUG. + */ + 'dev_tools' => [ + 'enabled' => env('SCRAMBLE_DEV_TOOLS', env('APP_DEBUG', false)), + ], + + 'renderer' => 'elements', + + 'renderers' => [ + /* + * Stoplight Elements config options: https://docs.stoplight.io/docs/elements/b074dc47b2826-elements-configuration-options + */ + 'elements' => [ + 'view' => 'scramble::docs', + 'theme' => 'light', + 'hideTryIt' => false, + 'hideSchemas' => true, + 'logo' => '', + 'tryItCredentialsPolicy' => 'include', + 'layout' => 'responsive', + 'router' => 'hash', + ], + /* + * Scalar API reference config options: https://scalar.com/products/api-references/configuration + */ + 'scalar' => [ + 'view' => 'scramble::scalar', + 'cdn' => 'https://cdn.jsdelivr.net/npm/@scalar/api-reference', + 'theme' => 'laravel', + 'proxyUrl' => 'https://proxy.scalar.com', + 'darkMode' => false, + 'showDeveloperTools' => 'never', + 'agent' => ['disabled' => true], + 'credentials' => '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, + + /** + * Determines how Scramble stores the descriptions of enum cases. + * Available options: + * - 'description' – Case descriptions are stored as the enum schema's description using table formatting. + * - 'extension' – Case descriptions are stored in the `x-enumDescriptions` enum schema extension. + * + * @see https://redocly.com/docs-legacy/api-reference-docs/specification-extensions/x-enum-descriptions + * - false - Case descriptions are ignored. + */ + 'enum_cases_description_strategy' => 'description', + + /** + * Determines how Scramble stores the names of enum cases. + * Available options: + * - 'names' – Case names are stored in the `x-enumNames` enum schema extension. + * - 'varnames' - Case names are stored in the `x-enum-varnames` enum schema extension. + * - false - Case names are not stored. + */ + 'enum_cases_names_strategy' => false, + + /** + * When Scramble encounters deep objects in query parameters, it flattens the parameters so the generated + * OpenAPI document correctly describes the API. Flattening deep query parameters is relevant until + * OpenAPI 3.2 is released and query string structure can be described properly. + * + * For example, this nested validation rule describes the object with `bar` property: + * `['foo.bar' => ['required', 'int']]`. + * + * When `flatten_deep_query_parameters` is `true`, Scramble will document the parameter like so: + * `{"name":"foo[bar]", "schema":{"type":"int"}, "required":true}`. + * + * When `flatten_deep_query_parameters` is `false`, Scramble will document the parameter like so: + * `{"name":"foo", "schema": {"type":"object", "properties":{"bar":{"type": "int"}}, "required": ["bar"]}, "required":true}`. + */ + 'flatten_deep_query_parameters' => true, + + // Token akses halaman /docs diambil dari DOCS_TOKEN (lihat App\Http\Middleware\DocsToken). + 'docs_token' => env('DOCS_TOKEN'), + + /* + * Endpoint yang ditampilkan di /docs, berupa pola URI route (mendukung wildcard `*`). + * Kosongkan ([]) untuk menampilkan semua endpoint. Contoh: + * 'visible_routes' => [], + */ + 'visible_routes' => ['api/v1/pengajuan-absen*'], + + 'middleware' => [ + DocsToken::class, + ], + + 'extensions' => [], + + /* + * Automatically document API security (OpenAPI `security` / `securitySchemes`) based on route + * middleware. + * + * Disabled by default. Uncomment the line below to enable `MiddlewareAuthSecurityStrategy`. + * When at least one documented route uses middleware matching the configured patterns (by default + * `auth` and `auth:*`), bearer auth is applied globally. Routes without matching middleware are + * marked as public (`security: []`). + * + * Set to `null` explicitly to disable. If you already configure security manually via + * `afterOpenApiGenerated` / `extendOpenApi`, keep this disabled to avoid duplicate schemes. + * + * Customize with a class-string or [class, options]: + * + * 'security_strategy' => [ + * \Dedoc\Scramble\SecurityDocumentation\MiddlewareAuthSecurityStrategy::class, + * [ + * 'middleware' => ['auth', 'auth:*'], + * 'scheme' => \Dedoc\Scramble\Support\Generator\SecurityScheme::http('bearer'), + * ], + * ], + */ + // 'security_strategy' => \Dedoc\Scramble\SecurityDocumentation\MiddlewareAuthSecurityStrategy::class, + 'security_strategy' => null, +]; diff --git a/resources/views/errors/docs-unauthorized.blade.php b/resources/views/errors/docs-unauthorized.blade.php new file mode 100644 index 00000000..dc2cb63d --- /dev/null +++ b/resources/views/errors/docs-unauthorized.blade.php @@ -0,0 +1,24 @@ + + + + + + Akses Ditolak | {{ config('app.name') }} + + + + + +
+ UNTAN +

Akses Ditolak

+

{{ $message }}

+
+ + diff --git a/resources/views/vendor/scramble/docs.blade.php b/resources/views/vendor/scramble/docs.blade.php new file mode 100644 index 00000000..b72ed2c3 --- /dev/null +++ b/resources/views/vendor/scramble/docs.blade.php @@ -0,0 +1,234 @@ + + + + + + + {{ $config->get('ui.title') ?? config('app.name') . ' - API Docs' }} + + + + + + + + @include('scramble::dev-tools', ['renderer' => 'elements']) + + + + + + +@php + $verifMethods = ['get', 'post', 'put', 'patch', 'delete']; + $verifGroups = []; + foreach (($spec['paths'] ?? []) as $verifPath => $verifItem) { + foreach ($verifItem as $verifMethod => $verifOp) { + if (! in_array($verifMethod, $verifMethods, true) || empty($verifOp['operationId'])) { + continue; + } + $verifGroups[$verifOp['tags'][0] ?? 'Lainnya'][] = [ + 'id' => $verifOp['operationId'], + 'method' => $verifMethod, + 'label' => $verifOp['summary'] ?? $verifPath, + 'path' => $verifPath, + ]; + } + } +@endphp + +
+
+ API Documentation +
+
+renderer()->all(except: ['theme']) as $key => $value) + @continue(! $value) + {{ $key }}="{{ $value === true ? 'true' : ($value === false ? 'false' : $value) }}" + @endforeach +/> + + +@if($config->renderer()->get('theme', 'light') === 'system') + +@endif +
+
+ +