fix swagger docs

This commit is contained in:
root
2026-03-10 18:29:09 -04:00
parent 25e7b3c67c
commit ba1206e314
4 changed files with 24 additions and 3 deletions
+22 -1
View File
@@ -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
+1 -1
View File
@@ -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": [
{
+1 -1
View File
@@ -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
View File
Binary file not shown.