rheienfolge
This commit is contained in:
@@ -126,55 +126,46 @@ builder.Services.AddEndpointsApiExplorer();
|
||||
// Swagger / OpenAPI Konfiguration
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
// --- 1. Gruppierung der Endpunkte (mit Unterpunkten) ---
|
||||
// --- 1. Gruppierung der Endpunkte (visuelle Tags) ---
|
||||
c.TagActionsBy(api =>
|
||||
{
|
||||
// Der Name des Controllers wird als Unterpunkt verwendet (z.B. "Products", "Users")
|
||||
// Wir entfernen das "Controller"-Suffix f<>r einen sauberen Tag.
|
||||
var controllerName = api.ActionDescriptor.RouteValues["controller"];
|
||||
if (controllerName == null)
|
||||
{
|
||||
return new[] { "Default" };
|
||||
}
|
||||
var tag = controllerName.Replace("Admin", "").Replace("Controller", ""); // Entfernt Pr<50>fixe/Suffixe
|
||||
if (controllerName == null) return new[] { "Default" };
|
||||
|
||||
// Bereinige den Controller-Namen f<>r einen sauberen Tag
|
||||
var tag = controllerName.Replace("Admin", "").Replace("Controller", "");
|
||||
|
||||
|
||||
if (api.RelativePath.StartsWith("api/v1/auth"))
|
||||
{
|
||||
// Auth hat normalerweise nur einen Controller, daher keine Untergruppe
|
||||
return new[] { "Auth" };
|
||||
|
||||
}
|
||||
// Erkenne den Hauptbereich anhand des Routen-Pr<50>fixes
|
||||
if (api.RelativePath.StartsWith("api/v1/admin"))
|
||||
{
|
||||
// Erzeugt einen Tag wie "Admin - Products", "Admin - Users" etc.
|
||||
return new[] { $"Admin - {tag}" };
|
||||
}
|
||||
if (api.RelativePath.StartsWith("api/v1/customer"))
|
||||
{
|
||||
// Erzeugt einen Tag wie "Customer - Profile", "Customer - Orders"
|
||||
return new[] { $"Customer - {tag}" };
|
||||
}
|
||||
if (api.RelativePath.StartsWith("api/v1/public"))
|
||||
{
|
||||
// Erzeugt einen Tag wie "Public - Products", "Public - Categorys"
|
||||
return new[] { $"Public - {tag}" };
|
||||
}
|
||||
|
||||
// Fallback-Tag
|
||||
return new[] { tag };
|
||||
});
|
||||
|
||||
// --- NEU: Sortierung der Gruppen in der UI ---
|
||||
c.OrderActionsBy(apiDesc =>
|
||||
{
|
||||
var relativePath = apiDesc.RelativePath ?? "";
|
||||
|
||||
// Die Reihenfolge der if-Bedingungen HIER ist entscheidend f<>r die Sortierung!
|
||||
if (relativePath.StartsWith("api/v1/auth")) return "1"; // Auth ganz oben
|
||||
if (relativePath.StartsWith("api/v1/admin")) return "2"; // Admin als letztes
|
||||
if (relativePath.StartsWith("api/v1/public")) return "2"; // Public als n<>chstes
|
||||
if (relativePath.StartsWith("api/v1/customer")) return "3"; // Customer danach
|
||||
if (relativePath.StartsWith("api/v1/public")) return "4"; // Public als n<>chstes
|
||||
|
||||
|
||||
if (relativePath.StartsWith("api/v1/admin")) return "4"; // Admin als letztes
|
||||
|
||||
return "5"; // Fallback
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user