简单Swagger

master
bicijinlian 4 years ago
parent d9c6a758c8
commit 962eed37a9

@ -74,6 +74,9 @@ namespace AccessStudy.WebApi.Controllers
/// 请求例子:
/// GET /api/Student/GetByName?studentName=王高峰
/// </remarks>
/// <example>
/// GET /api/Student/GetByName?studentName=王高峰
/// </example>
/// <returns></returns>
[HttpGet]
public ResultBase GetByName(string studentName)

@ -34,6 +34,7 @@ namespace AccessStudy.WebApi
//services.AddScoped<IStudentIDal,StudentOdbcDal>();
services.AddScoped<IStudentIDal,StudentOledbDal>();
#region Swagger
services.AddSwaggerGen(option =>
{
option.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo() { Title = "API", Version = "v1" });
@ -41,13 +42,21 @@ namespace AccessStudy.WebApi
// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = System.IO.Path.Combine(AppContext.BaseDirectory, xmlFile);
option.IncludeXmlComments(xmlPath);
//不显示控制器注释
//option.IncludeXmlComments(xmlPath);
//显示控制器注释
option.IncludeXmlComments(xmlPath, true);
});
//services.ConfigureSwaggerGen(option =>
//{
//});
#endregion
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

Loading…
Cancel
Save