本文介绍了AspNetCore无法加载类型'Swashbuckle.AspNetCore.SwaggerGen.SwaggerResponseAttribute'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ASP.NET Core Web应用程序,在其中使用以下命令:
I have ASP.NET Core Web application where I am using swagger using the following:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSwaggerGen(c =>
{
c.OperationFilter<ExamplesOperationFilter>();
c.OperationFilter<DescriptionOperationFilter>();
c.SwaggerDoc("v1", new Info
{
Version = "v1",
Title = "API",
Description = "",
});
// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseSwagger();
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API"); });
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
当我导航到url/swagger时,出现以下错误:
When I navigate to url/swagger I am getting the following error:
我安装的nuget软件包是:
The nuget packages I installed are:
Swashbuckle.AspNetCore v3.0.0
Swashbuckle.AspNetCore v3.0.0
Swashbuckle.AspNetCore.Examples v2.9.0
Swashbuckle.AspNetCore.Examples v2.9.0
推荐答案
将Swashbuckle.AspNetCore滚动回v2.5.0可以达到目的
Rolling back Swashbuckle.AspNetCore to v2.5.0 did the trick
这篇关于AspNetCore无法加载类型'Swashbuckle.AspNetCore.SwaggerGen.SwaggerResponseAttribute'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!