获取操作对象 Swagger 2.0 的方法

Getting the method of an Operation Object Swagger 2.0

这可能是一个非常简单的问题,但我似乎无法弄清楚。如何使用 swagger 2.0 获取 Operations 对象的方法?

来自过渡指南: "The structure of most objects has changed (such as the Operation Object, the Parameter Object). Among other changes, in many cases instead of stating the type of the object, the property name directing to the object will state its type. For example, for operations, you would have a property name called "get" 指向操作对象。因此,方法字段从对象本身中删除。"

https://github.com/swagger-api/swagger-spec/wiki/Swagger-1.2-to-2.0-Migration-Guide

所以我的问题是,如果您有一个操作对象,您将如何获得该方法?具体在 c# 中?

我正在尝试将我的操作过滤器从 1.2 迁移到 2.0

void IOperationFilter.Apply(Swashbuckle.Swagger.Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
        {
            if (apiDescription.ActionDescriptor.ReturnType == typeof(HttpResponseMessage))
            {
                switch (operation.Method)
                {
                    ...

                }
            }

但是 operation.Method 在 swagger 2.0 中不再可用。

在 swagger 2.0 中,操作的结构发生了变化,因此方法类型不再具有 属性。因此,如果您拥有操作对象,则无法获取该方法,但 ApiDescription 具有一个 HttpMethod 属性,该属性将指示该操作是 Get、Put、Post 还是 Delete。现在可以使用

检索以前 operation.Method 的内容
apiDescription.HttpMethod.ToString()