Manually set operationId to allow multiple operations with the same verb in Swashbuckle

EDIT This answer relates to Swashbuckle 5.6 and .NET Framework. Please read mwilson’s answer for Swashbuckle and .NET Core

You can use the SwaggerOperationAttribute provided by Swashbuckle for that.

[SwaggerOperation("get")]
public IEnumerable<Contact> Get()
{
    ....
}

[SwaggerOperation("getById")]
public IEnumerable<Contact> Get(string id)
{
    ...
}

You can use that attribute to add tags and schemes to your operation as well by the way. Have a look at the source code

Leave a Comment