feat: add internal api docs to /docs/api with auth
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\InstanceSettings;
|
|||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\Process;
|
use Illuminate\Support\Facades\Process;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
class Dev extends Command
|
class Dev extends Command
|
||||||
{
|
{
|
||||||
@@ -37,6 +38,11 @@ class Dev extends Command
|
|||||||
$error = preg_replace('/^\h*\v+/m', '', $error);
|
$error = preg_replace('/^\h*\v+/m', '', $error);
|
||||||
echo $error;
|
echo $error;
|
||||||
echo $process->output();
|
echo $process->output();
|
||||||
|
// Convert YAML to JSON
|
||||||
|
$yaml = file_get_contents('openapi.yaml');
|
||||||
|
$json = json_encode(Yaml::parse($yaml), JSON_PRETTY_PRINT);
|
||||||
|
file_put_contents('openapi.json', $json);
|
||||||
|
echo "Converted OpenAPI YAML to JSON.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
|
"3sidedcube/laravel-redoc": "^1.0",
|
||||||
"danharrin/livewire-rate-limiting": "^1.1",
|
"danharrin/livewire-rate-limiting": "^1.1",
|
||||||
"doctrine/dbal": "^3.6",
|
"doctrine/dbal": "^3.6",
|
||||||
"guzzlehttp/guzzle": "^7.5.0",
|
"guzzlehttp/guzzle": "^7.5.0",
|
||||||
|
60
composer.lock
generated
60
composer.lock
generated
@@ -4,8 +4,66 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "3f2342fe6b1ba920c8875f8a8fe41962",
|
"content-hash": "b9f4772191b4680e6f92fa9c7c396b10",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "3sidedcube/laravel-redoc",
|
||||||
|
"version": "v1.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/3sidedcube/laravel-redoc.git",
|
||||||
|
"reference": "c33a563885dcdf1e0f623df5a56c106d130261da"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/3sidedcube/laravel-redoc/zipball/c33a563885dcdf1e0f623df5a56c106d130261da",
|
||||||
|
"reference": "c33a563885dcdf1e0f623df5a56c106d130261da",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/routing": "^8.0|^9.0|^10.0|^11.0",
|
||||||
|
"illuminate/support": "^8.0|^9.0|^10.0|^11.0",
|
||||||
|
"php": "^7.4|^8.0|^8.1|^8.2|^8.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^3.3",
|
||||||
|
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"ThreeSidedCube\\LaravelRedoc\\RedocServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"ThreeSidedCube\\LaravelRedoc\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Ben Sherred",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A lightweight package for rendering API documentation using OpenAPI and Redoc.",
|
||||||
|
"homepage": "https://github.com/3sidedcube/laravel-redoc",
|
||||||
|
"keywords": [
|
||||||
|
"3sidedcube",
|
||||||
|
"laravel-redoc"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/3sidedcube/laravel-redoc/issues",
|
||||||
|
"source": "https://github.com/3sidedcube/laravel-redoc/tree/v1.0.1"
|
||||||
|
},
|
||||||
|
"time": "2024-05-20T11:37:55+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "amphp/amp",
|
"name": "amphp/amp",
|
||||||
"version": "v3.0.2",
|
"version": "v3.0.2",
|
||||||
|
28
config/redoc.php
Normal file
28
config/redoc.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Directory
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The name of the directory where your OpenAPI definitions are stored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'directory' => '',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Variables
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You can automatically replace variables in your OpenAPI definitions by
|
||||||
|
| adding a key value pair to the array below. This will replace any
|
||||||
|
| instances of :key with the given value.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'variables' => [],
|
||||||
|
|
||||||
|
];
|
7941
openapi.json
Normal file
7941
openapi.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -68,7 +68,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2 md:flex-row flex-col w-full">
|
||||||
<x-forms.input id="public_ipv4" type="password" label="Instance's IPv4"
|
<x-forms.input id="public_ipv4" type="password" label="Instance's IPv4"
|
||||||
helper="Enter the IPv4 address of the instance.<br><br>It is useful if you have several IPv4 addresses and Coolify could not detect the correct one."
|
helper="Enter the IPv4 address of the instance.<br><br>It is useful if you have several IPv4 addresses and Coolify could not detect the correct one."
|
||||||
placeholder="1.2.3.4" />
|
placeholder="1.2.3.4" />
|
||||||
@@ -92,6 +92,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<h4 class="pt-6">API</h4>
|
<h4 class="pt-6">API</h4>
|
||||||
|
<div class="pb-4">For API documentation, please visit <a class="dark:text-warning underline"
|
||||||
|
href="/docs/api">/docs/api</a></div>
|
||||||
<div class="md:w-96 pb-2">
|
<div class="md:w-96 pb-2">
|
||||||
<x-forms.checkbox instantSave id="is_api_enabled" label="Enabled" />
|
<x-forms.checkbox instantSave id="is_api_enabled" label="Enabled" />
|
||||||
</div>
|
</div>
|
||||||
@@ -131,9 +133,11 @@
|
|||||||
|
|
||||||
<h4 class="py-4">Confirmation Settings</h4>
|
<h4 class="py-4">Confirmation Settings</h4>
|
||||||
<div x-data="{ open: false }" class="mb-32 md:w-[40rem]">
|
<div x-data="{ open: false }" class="mb-32 md:w-[40rem]">
|
||||||
<button type="button" @click.prevent="open = !open" class="flex items-center justify-between w-full p-4 bg-coolgray-100 hover:bg-coolgray-200 rounded-md">
|
<button type="button" @click.prevent="open = !open"
|
||||||
|
class="flex items-center justify-between w-full p-4 bg-coolgray-100 hover:bg-coolgray-200 rounded-md">
|
||||||
<span class="font-medium">Two-Step Confirmation Settings</span>
|
<span class="font-medium">Two-Step Confirmation Settings</span>
|
||||||
<svg class="w-5 h-5 transition-transform" :class="{ 'rotate-180': open }" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg class="w-5 h-5 transition-transform" :class="{ 'rotate-180': open }" fill="none"
|
||||||
|
stroke="currentColor" viewBox="0 0 24 24">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
@@ -141,24 +145,28 @@
|
|||||||
<div x-show="open" x-transition class="mt-4">
|
<div x-show="open" x-transition class="mt-4">
|
||||||
@if ($disable_two_step_confirmation)
|
@if ($disable_two_step_confirmation)
|
||||||
<div class="md:w-96 pb-4">
|
<div class="md:w-96 pb-4">
|
||||||
<x-forms.checkbox instantSave id="disable_two_step_confirmation" label="Disable Two Step Confirmation"
|
<x-forms.checkbox instantSave id="disable_two_step_confirmation"
|
||||||
|
label="Disable Two Step Confirmation"
|
||||||
helper="When disabled, you will not need to confirm actions with a text and user password. This significantly reduces security and may lead to accidental deletions or unwanted changes. Use with extreme caution, especially on production servers." />
|
helper="When disabled, you will not need to confirm actions with a text and user password. This significantly reduces security and may lead to accidental deletions or unwanted changes. Use with extreme caution, especially on production servers." />
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="md:w-96 pb-4">
|
<div class="md:w-96 pb-4">
|
||||||
<x-modal-confirmation title="Disable Two Step Confirmation?"
|
<x-modal-confirmation title="Disable Two Step Confirmation?"
|
||||||
buttonTitle="Disable Two Step Confirmation" isErrorButton submitAction="toggleTwoStepConfirmation"
|
buttonTitle="Disable Two Step Confirmation" isErrorButton
|
||||||
:actions="[
|
submitAction="toggleTwoStepConfirmation" :actions="[
|
||||||
'Tow Step confimation will be disabled globally.',
|
'Tow Step confimation will be disabled globally.',
|
||||||
'Disabling two step confirmation reduces security (as anyone can easily delete anything).',
|
'Disabling two step confirmation reduces security (as anyone can easily delete anything).',
|
||||||
'The risk of accidental actions will increase.',
|
'The risk of accidental actions will increase.',
|
||||||
]" confirmationText="DISABLE TWO STEP CONFIRMATION"
|
]"
|
||||||
|
confirmationText="DISABLE TWO STEP CONFIRMATION"
|
||||||
confirmationLabel="Please type the confirmation text to disable two step confirmation."
|
confirmationLabel="Please type the confirmation text to disable two step confirmation."
|
||||||
shortConfirmationLabel="Confirmation text" step3ButtonText="Disable Two Step Confirmation" />
|
shortConfirmationLabel="Confirmation text"
|
||||||
|
step3ButtonText="Disable Two Step Confirmation" />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full px-4 py-2 mb-4 text-white rounded-sm border-l-4 border-red-500 bg-error">
|
<div class="w-full px-4 py-2 mb-4 text-white rounded-sm border-l-4 border-red-500 bg-error">
|
||||||
<p class="font-bold">Warning!</p>
|
<p class="font-bold">Warning!</p>
|
||||||
<p>Disabling two step confirmation reduces security (as anyone can easily delete anything) and increases
|
<p>Disabling two step confirmation reduces security (as anyone can easily delete anything) and
|
||||||
|
increases
|
||||||
the risk of accidental actions. This is not recommended for production servers.</p>
|
the risk of accidental actions. This is not recommended for production servers.</p>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
@@ -4,6 +4,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Http\Controllers\MagicController;
|
use App\Http\Controllers\MagicController;
|
||||||
use App\Http\Controllers\OauthController;
|
use App\Http\Controllers\OauthController;
|
||||||
use App\Http\Controllers\UploadController;
|
use App\Http\Controllers\UploadController;
|
||||||
|
use App\Http\Middleware\ApiAllowed;
|
||||||
use App\Livewire\Admin\Index as AdminIndex;
|
use App\Livewire\Admin\Index as AdminIndex;
|
||||||
use App\Livewire\Boarding\Index as BoardingIndex;
|
use App\Livewire\Boarding\Index as BoardingIndex;
|
||||||
use App\Livewire\Dashboard;
|
use App\Livewire\Dashboard;
|
||||||
@@ -72,13 +73,18 @@ use App\Livewire\Team\Member\Index as TeamMemberIndex;
|
|||||||
use App\Livewire\Terminal\Index as TerminalIndex;
|
use App\Livewire\Terminal\Index as TerminalIndex;
|
||||||
use App\Models\GitlabApp;
|
use App\Models\GitlabApp;
|
||||||
use App\Models\ScheduledDatabaseBackupExecution;
|
use App\Models\ScheduledDatabaseBackupExecution;
|
||||||
use App\Models\Server;
|
|
||||||
use App\Providers\RouteServiceProvider;
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
use ThreeSidedCube\LaravelRedoc\Http\Controllers\DefinitionController;
|
||||||
|
use ThreeSidedCube\LaravelRedoc\Http\Controllers\DocumentationController;
|
||||||
|
|
||||||
|
Route::group(['middleware' => ['auth:sanctum', ApiAllowed::class]], function () {
|
||||||
|
Route::get('/docs/api', DocumentationController::class)->name('redoc.documentation');
|
||||||
|
Route::get('/docs/api/definition', DefinitionController::class)->name('redoc.definition');
|
||||||
|
});
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
Route::get('/dev/compose', Compose::class)->name('dev.compose');
|
Route::get('/dev/compose', Compose::class)->name('dev.compose');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user