.netcore2.2使用Swagger
2021-05-07 05:29
标签:get version none dex dir oca 联系人 desc code 1.swagger的引用 2.项目属性更改。勾选xml文档文件 3.在ConfigureServices中注册 4.在Configure中添加中间件 5.项目启动 .netcore2.2使用Swagger 标签:get version none dex dir oca 联系人 desc code 原文地址:https://www.cnblogs.com/papermask/p/12092874.html引用Swashbuckle.AspNetCore和Swashbuckle.AspNetCore.Swagger
#region swagger
//注册Swagger生成器,定义一个和多个Swagger 文档
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info
{
Version = "v1", //版本
Title = "hl's API", //标题
Description = "API描述",//描述
TermsOfService = "None",
Contact = new Contact //联系人信息
{
Name = "**",
Email = string.Empty,
}
});
// 为 Swagger JSON and UI设置xml文档注释路径
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
var xmlPath = Path.Combine(basePath, "Test.xml");//xml路径名称
c.IncludeXmlComments(xmlPath);
});
#endregion
//启用中间件服务生成Swagger作为JSON终结点
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
c.RoutePrefix = string.Empty;
});
上一篇:页面重置样式reset.css
文章标题:.netcore2.2使用Swagger
文章链接:http://soscw.com/index.php/essay/83543.html