我在学习.NET CORE 3.1 WEBAPI项目中配置SWAGGER,最后并没有出来想要的界面(界面如下图),不知道如何处理,向各位专家请教。
另外,在我程序中,有好几个Controllers页(例如:BindingWechatController,CustomerController,WeatherForecastController等等),程序是怎么知道应该调用哪个页面的呢?
代码:
```c#
namespace expressApi
{
public class Startup
{
///// <summary>
///// </summary>
//public static ILoggerRepository repository { get; set; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
/// <summary>
/// 依赖注入
/// </summary>
/// <param name="services"></param>
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(m => m.SwaggerDoc("v1", new OpenApiInfo
{
Title = "expressApi", //标题
Version = "v1",
Description = $".net core Http API v1" //描述
})
);
}
private static void Register(IServiceCollection services)
{
}
/// <summary>
/// 依赖注入
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(m => m.SwaggerEndpoint("/swagger/v1/swagger.json", "expressApi"));
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
```
问题界面