nuget安装包:Swashbuckle.AspNetCore.SwaggerGen
nuget安装包:Swashbuckle.AspNetCore.SwaggerUI
using Microsoft.OpenApi.Models;
using Xiaowu_Ship.AutoMapper;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddAutoMapper(typeof(AutoMapProfile));
builder.Services.AddSwaggerGen(m => {
m.SwaggerDoc("v1", new OpenApiInfo { Title = "小五测试", Version = "v1" });
});
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseSwagger();
app.UseSwaggerUI(s => {
//下面路径里的v1必须和SwaggerDoc()第一个参数一致
s.SwaggerEndpoint("/swagger/v1/swagger.json", "swaggerTast");
});
app.UseAuthorization();
app.MapControllers();
app.Run();
标签:builder,v1,6.0,Services,net,swagger,安装包,app From: https://www.cnblogs.com/wugh8726254/p/16950715.html