diff --git a/AccessStudy.WebApi/Controllers/StudentController.cs b/AccessStudy.WebApi/Controllers/StudentController.cs index e1cead7..2f9fb97 100644 --- a/AccessStudy.WebApi/Controllers/StudentController.cs +++ b/AccessStudy.WebApi/Controllers/StudentController.cs @@ -74,6 +74,9 @@ namespace AccessStudy.WebApi.Controllers /// 请求例子: /// GET /api/Student/GetByName?studentName=王高峰 /// + /// + /// GET /api/Student/GetByName?studentName=王高峰 + /// /// [HttpGet] public ResultBase GetByName(string studentName) diff --git a/AccessStudy.WebApi/Startup.cs b/AccessStudy.WebApi/Startup.cs index 3213654..605a1e7 100644 --- a/AccessStudy.WebApi/Startup.cs +++ b/AccessStudy.WebApi/Startup.cs @@ -34,6 +34,7 @@ namespace AccessStudy.WebApi //services.AddScoped(); services.AddScoped(); + #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.