大摇大摆的划掉方法 [英] Swagger cross out method

查看:34
本文介绍了大摇大摆的划掉方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我查看了来自

我想在我的 api 服务中划掉一个动作,但是当我使用过时的属性时,这个动作是不可见的.

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

解决方案

我的 WebApi 项目遇到了同样的问题,但是在将 Swashbuckle.Core nuget 包更新到版本 5.6.0 后它开始工作了.

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

公共静态类 SwaggerConfig{公共静态无效注册(HttpConfiguration配置){configuration.EnableSwagger(Configure).EnableSwaggerUi(ConfigureUi);}静态无效配置(SwaggerDocsConfig 配置){config.SingleApiVersion("V1", "MichalBialecki.com.Swagger.Example");config.UseFullTypeNameInSchemaIds();}静态无效 ConfigureUi(SwaggerUiConfig 配置){config.DocExpansion(DocExpansion.None);config.DisableValidator();}}

还需要在 Startup.cs 中注册:

SwaggerConfig.Register(config);

在 ApiController 中使用这样的方法:

[HttpGet][Obsolete("此方法已过时,请使用/accounts/{accountId}")][Route("personalAccount/{accountId}")]public AccountDTO GetPersonalAccount(int accountId)

我可以在 Swagger 中看到,它被抚平了:

I am using Swaschbuckle for my .NET Swagger Web API Service.

I have looked at the sample from http://petstore.swagger.io/#/pet and there ist the Action findByTags which is crossed out.

I want to cross out an action in my api service, but when i am using the obsolete attribute the action isn't visible.

Any idea how to handle this issue?

解决方案

I had the same problem with my WebApi project, but after updating Swashbuckle.Core nuget package to version 5.6.0 it started to work.

I have a SwaggerConfig class that looks like this:

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();
    }
}

You also need to register it in Startup.cs:

SwaggerConfig.Register(config);

And with method in ApiController like this:

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

I can see in Swagger, that it is stroked out:

这篇关于大摇大摆的划掉方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆