- Nuget 添加 Swashbuckle.AspNetCore
- StartUp.cs 文件添加内容
public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "Core API"
});
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(basePath, xmlFile);
options.IncludeXmlComments(xmlPath);
});
}
************
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "CoreApi Docs");
});
}
- API属性 生成页签 xml生成添加路径