【1】安装Swashbuckle.AspNetCore包
【2】在Startup.cs中注册swagger
//注册Swagger生成器,定义一个和多个Swagger 文档 services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "爱住微订API", Version = "v1" }); });
【3】在Startup.cs中配置swagger
app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "爱住微订API V1"); c.RoutePrefix = string.Empty;//设置后直接输入IP就可以进入接口文档 });
【4】在launchSettings.json中修改启动地址
"launchUrl": "swagger",
原文地址:https://www.cnblogs.com/mobaiyu/p/10844944.html
时间: 2024-10-10 21:39:34