From ff504264250778650d6ccde7b85f6f44120cdf6c Mon Sep 17 00:00:00 2001 From: "Matt Parker [SSW]" <61717342+MattParkerDev@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:13:54 +1000 Subject: [PATCH] Update AspNetCoreOpenApiDocumentGenerator.cs --- .../AspNetCoreOpenApiDocumentGenerator.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs b/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs index b9fa02ff52..306b28e076 100644 --- a/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs +++ b/src/NSwag.Generation.AspNetCore/AspNetCoreOpenApiDocumentGenerator.cs @@ -15,6 +15,7 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.ApiExplorer; @@ -532,6 +533,12 @@ private string GetOperationId(OpenApiDocument document, ApiDescription apiDescri .FirstOrDefault()? .RouteName; + var prefix = apiDescription.ActionDescriptor.EndpointMetadata.OfType().FirstOrDefault()?.Tags.FirstOrDefault(); + if (!string.IsNullOrWhiteSpace(prefix)) + { + routeName = prefix + "_" + routeName; + } + if (routeName != null) { return routeName;