gpt4 book ai didi

.net - Swagger 的划掉方法

转载 作者:行者123 更新时间:2023-12-04 21:09:38 25 4
gpt4 key购买 nike

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

我看了看http://petstore.swagger.io/#/pet的示例,然后发现了被删除的Action findByTags。

enter image description here

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

任何想法如何处理这个问题?

最佳答案

我的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

关于.net - Swagger 的划掉方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37350241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com