标签:文档 point bsp include col 方法 sem 接口 最简
1, 引用第三方包,
Swashbuckle.AspNetCore
Swashbuckle.AspNetCore.Swagger
Swashbuckle.AspNetCore.SwaggerUI
最简单方法复制:
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" /> <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="4.0.1" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="4.0.1" />
2. startup.cs
//swagger services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Version = "v1", Title = typeof(Startup).GetTypeInfo().Assembly.GetName().Name }); });
3
app.UseSwagger().UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", typeof(Startup).GetTypeInfo().Assembly.GetName().Name + "-v1"); });
4. Controllers
对外action 加上请求方式
[HttpPost] [HttpGet]...
访问地址:http://localhost:{端口}/swagger/index.html
标签:文档 point bsp include col 方法 sem 接口 最简
原文地址:https://www.cnblogs.com/Yang33033/p/10283353.html