1.添加包Swashbuckle.AspNetCore
2.在ConfigureServices中添加
#region Swagger注册 services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Demo", Version = "v1" }); }); #endregion
在Configure()中添加
#region 使用Swagger app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swaagger.json", "Demo v1"); }); #endregion