Swagger交叉方法

时间:2016-05-20 15:22:44

标签: .net asp.net-web-api swagger swagger-ui swashbuckle

我正在使用Swaschbuckle作为我的.NET Swagger Web API服务。

我查看了来自http://petstore.swagger.io/#/pet的示例,并且已经删除了动作findByTags。

enter image description here

我想在我的api服务中删除一个动作,但是当我使用过时的属性时,动作是不可见的。

知道如何处理这个问题吗?

1 个答案:

答案 0 :(得分:2)

我的WebApi项目遇到了同样的问题,但在将Swashbuckle.Core nuget软件包更新到5.6.0后,它开始运行。

我有一个SwaggerConfig类,如下所示:

public static class SwaggerConfig
{
    public static void Register(HttpConfiguration configuration)
    {
        configuration.EnableSwagger(Configure).EnableSwaggerUi(ConfigureUi);

    }

    static void Configure(SwaggerDocsConfig config)
    {
        config.SingleApiVersion("V1", "MichalBialecki.com.Swagger.Example");
        config.UseFullTypeNameInSchemaIds();
    }

    static void ConfigureUi(SwaggerUiConfig config)
    {
        config.DocExpansion(DocExpansion.None);
        config.DisableValidator();
    }
}

您还需要在Startup.cs中注册它:

SwaggerConfig.Register(config);

使用ApiController中的方法,如下所示:

[HttpGet]
[Obsolete("This method is obsolete, please use /accounts/{accountId}")]
[Route("personalAccount/{accountId}")]
public AccountDTO GetPersonalAccount(int accountId)

我可以在Swagger中看到它被描述出来: enter image description here