I need to know if it\'s possible to set up custom operationid, or a naming convention, I mean I know that operation filter can be overwritten the way how operationId is gene
For swashbuckle 5.0, you can use the Name
attribute. You can set it to any string
but I'm a fan of using nameof
like this: nameof(ActualMethodName)
.
[HttpGet("{id:int}", Name = nameof(GetProductById))]
public IActionResult GetProductById(int id) // operationId = "GetProductById"'
or
[HttpGet("{id:int}", Name = "GetProductById")]
public IActionResult GetProductById(int id) // operationId = "GetProductById"'
There are a few other options listed here
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