昂首阔步的划掉方法 [英] Swagger cross out method

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

问题描述

我正在将Swaschbuckle用于我的.NET Swagger Web API服务.

我已经查看了

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

有什么想法要解决这个问题吗?

解决方案

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

我有一个类似SwaggerConfig的类:

 公共静态类SwaggerConfig{公共静态无效寄存器(HttpConfiguration配置){configuration.EnableSwagger(Configure).EnableSwaggerUi(ConfigureUi);}静态void Configure(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][已过时(此方法已过时,请使用/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天全站免登陆