相关疑难解决方法(0)

AspNetCore 无法加载类型“Swashbuckle.AspNetCore.SwaggerGen.SwaggerResponseAttribute”

我有 ASP.NET Core Web 应用程序,我在其中使用 swagger 使用以下内容:

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();
}
Run Code Online (Sandbox Code Playgroud)

当我导航到 url/swagger 时,出现以下错误:

失败:Microsoft.AspNetCore.Server.Kestrel[13] …

c# swagger asp.net-core

9
推荐指数
3
解决办法
2万
查看次数

标签 统计

asp.net-core ×1

c# ×1

swagger ×1