diff --git a/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs b/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs index d74c5080d..99eacf606 100644 --- a/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs +++ b/src/NSwag.Generation.WebApi/WebApiOpenApiDocumentGenerator.cs @@ -222,7 +222,12 @@ private bool AddOperationDescriptionsToDocument(OpenApiDocument document, Type c if (pathItem.ContainsKey(operation.Method)) { - throw new InvalidOperationException($"The method '{operation.Method}' on path '{path}' is registered multiple times " + + var conflictingOperationDisplayNames = operations + .Where(t => t.Item1.Path == operation.Path && t.Item1.Method == operation.Method) + .Select(t => GetDisplayName(controllerType, t.Item2)) + .ToList(); + + throw new InvalidOperationException($"The method '{operation.Method}' on path '{path}' is registered multiple times for action {string.Join(", ", conflictingOperationDisplayNames)} " + "(check the DefaultUrlTemplate setting [default for Web API: 'api/{controller}/{id}'; for MVC projects: '{controller}/{action}/{id?}'])."); } @@ -234,6 +239,11 @@ private bool AddOperationDescriptionsToDocument(OpenApiDocument document, Type c return addedOperations > 0; } + private static string GetDisplayName(Type controllerType, MethodInfo method) + { + return $"{controllerType.FullName}.{method.Name} ({controllerType.Assembly.GetName().Name})"; + } + private bool RunOperationProcessors(OpenApiDocument document, Type controllerType, MethodInfo methodInfo, OpenApiOperationDescription operationDescription, List allOperations, OpenApiDocumentGenerator generator, OpenApiSchemaResolver schemaResolver) {