Swashbuckle set manually operationId, multiple operations with same verb

前端 未结 2 1488
北荒
北荒 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:37

    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 Get()
    {
        ....
    }
    
    [SwaggerOperation("getById")]
    public IEnumerable 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

提交回复
热议问题