Swagger 如何显示同一 Azure 函数的放置和获取版本?

How can Swagger show both put and get versions of the same Azure function?

我有一个带有以下声明的 Azure 函数 (V3)

[Function("GetCases")]
public async Task<HttpResponseData> GetCases([HttpTrigger(AuthorizationLevel.User, "put", "get", Route = "Case/{page}/{pageSize}/{sort}/{filter?}")] HttpRequestData req,
            FunctionContext executionContext, int page, int pageSize, string sort, string filter)
        {
            var logger = executionContext.GetLogger("GetCourtCases");
            logger.LogInformation("GetCourtCases function processed a request.");

            return await g.GetMany(req, page, pageSize, sort, filter);
        }

到 return 带有排序字符串和可选过滤器的分页数据集。那就是 GET 操作。使用 PUT,我可以发送一个 JSON object,其中包含值列表和应该搜索这些值的列。

所以基本上我有可以用 GET 或 PUT 调用的相同函数,其中 PUT 添加信息,如控制台所示:

问题是,使用 OpenAPI v0.9(最新预览版),swagger 只会显示其中一个配置,具体取决于函数标题中最先指定的配置。

我可以在描述中对此进行解释,但是有没有办法告诉 swagger 这既是 PUT 操作又是 GET 操作?

简而言之:不,没有办法告诉 Swagger 这个函数既是 GET 又是 PUT 操作。

详情见Justin Yoo's comment on the GitHub issue Doesn't support multiple operations (for example, GET, POST) for one endpoint

That's correct. Although technically one Function method can take more than one HTTP verb/method, semantically it should be two different operations.

Therefore, I would recommend separating multiple verbs/methods from each other, and giving them respective operation IDs.