.net core webapi 通过swagger生成说明文档

1.通过nuget安装 Swashbuckle.AspNetCore

2.startup.cs=>ConfigureServices,注册swagger

3.configure中添加:

app.UseSwagger();
app.UseSwaggerUI(c =>
{
  c.SwaggerEndpoint("/swagger/v1/swagger.json", "Web API V1");
});

4.启动项目,可以生成文说明文档

5.添加说明注释,点击站点属性=》“生成”标签,勾选“XML文档文件”

startup中配置

var path = Path.GetDirectoryName(typeof(Program).Assembly.Location);
var xPath = Path.Combine(path, "Qee.Api.xml");
c.IncludeXmlComments(xPath);

猜你喜欢

转载自www.cnblogs.com/qeewu/p/10105871.html