Swashbuckle set manually operationId, multiple operations with same verb

前端 未结 2 1487
北荒
北荒 2020-11-30 09:56

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

2条回答
  •  渐次进展
    2020-11-30 10:25

    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

提交回复
热议问题