By default SwashBuckle, doesn’t handle overloaded controller methods very well. A solution is the usage of an OperationFilter that changes the operationname in the UI:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Swashbuckle.Swagger; | |
using System.Web.Http.Description; | |
public class OperationOverloadingFilter : IOperationFilter | |
{ | |
public void Apply(Operation operation,SchemaRegistry schemaRegistry,ApiDescription apiDescription) | |
{ | |
if (operation.parameters != null) | |
{ | |
operation.operationId += "By"; | |
foreach (var param in operation.parameters) | |
{ | |
operation.operationId += $"param.name"; | |
} | |
} | |
} |
Next step is to add this OperationFilter to your Swagger configuration:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
httpConfiguration | |
.EnableSwagger(c => c.OperationFilter<OperationOverloadingFilter>();) |