fix swagger docs
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Services\Docs;
|
||||
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Facades\Route as RouteFacade;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class OpenApiRouteExporter
|
||||
{
|
||||
@@ -28,6 +29,10 @@ class OpenApiRouteExporter
|
||||
|
||||
private function mergeRoute(array &$paths, Route $route): void
|
||||
{
|
||||
if (!$this->isApiControllerRoute($route)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$uriRaw = ltrim($route->uri(), '/');
|
||||
if (str_starts_with($uriRaw, 'api/')) {
|
||||
$uri = '/' . $uriRaw;
|
||||
@@ -65,6 +70,16 @@ class OpenApiRouteExporter
|
||||
}
|
||||
}
|
||||
|
||||
private function isApiControllerRoute(Route $route): bool
|
||||
{
|
||||
$action = $route->getActionName();
|
||||
if (!is_string($action)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return str_starts_with($action, 'App\\Http\\Controllers\\Api\\');
|
||||
}
|
||||
|
||||
private function resolveTag(string $uri): string
|
||||
{
|
||||
$trimmed = trim(str_replace('/api/v1', '', $uri), '/');
|
||||
@@ -72,7 +87,13 @@ class OpenApiRouteExporter
|
||||
return 'api';
|
||||
}
|
||||
$segments = explode('/', $trimmed);
|
||||
return $segments[0] ?: 'api';
|
||||
$segment = $segments[0] ?: 'api';
|
||||
$normalized = Str::title(str_replace('-', ' ', $segment));
|
||||
$overrides = [
|
||||
'Whatsapp' => 'WhatsApp',
|
||||
];
|
||||
|
||||
return $overrides[$normalized] ?? $normalized;
|
||||
}
|
||||
|
||||
private function summaryFromAction(Route $route): string
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"info": {
|
||||
"title": "Alrahma Unified API",
|
||||
"version": "1.0.0",
|
||||
"description": "HTTP endpoints that power the Alrahma platform. Routes are namespaced under `/api/v1` unless noted otherwise."
|
||||
"description": "HTTP endpoints that power the Alrahma platform. Routes are namespaced under /api/v1 unless noted otherwise."
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<title>Alrahma API Docs</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css">
|
||||
<style>
|
||||
body { margin: 0; background: #0f172a; }
|
||||
body { margin: 0; background: #ffffff; }
|
||||
#swagger-ui { min-height: 100vh; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user