diff --git a/SwaggerStudy/ResultBase.cs b/SwaggerStudy/ResultBase.cs
index 26e9073..8f85039 100644
--- a/SwaggerStudy/ResultBase.cs
+++ b/SwaggerStudy/ResultBase.cs
@@ -5,14 +5,29 @@ using System.Threading.Tasks;
namespace SwaggerStudy
{
+ ///
+ /// 接口返回基类
+ ///
public class ResultBase
{
- public static ResultBase Default => new ResultBase() { Code=-1,Message=string.Empty};
+ ///
+ /// 获取默认基类的静态方法
+ ///
+ public static ResultBase Default => new ResultBase() { Code = -1, Message = string.Empty };
+ ///
+ /// 编码
+ ///
public int Code { get; set; } = 0;
+ ///
+ /// 消息
+ ///
public string Message { get; set; } = string.Empty;
+ ///
+ /// 数据(动态类型)
+ ///
public dynamic Data { get; set; }
}
}
diff --git a/SwaggerStudy/Startup02.cs b/SwaggerStudy/Startup02.cs
index ae299ac..9c87a7e 100644
--- a/SwaggerStudy/Startup02.cs
+++ b/SwaggerStudy/Startup02.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using System.Reflection;
using System.Threading.Tasks;
using System.Collections.Generic;
@@ -17,9 +18,9 @@ using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using Swashbuckle.AspNetCore.SwaggerUI;
-
using SwaggerStudy.Services;
+
namespace SwaggerStudy
{
///
@@ -67,7 +68,7 @@ namespace SwaggerStudy
#endregion
#region 包含xml注释
- var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"SwaggerStudy*.xml", System.IO.SearchOption.TopDirectoryOnly);
+ var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}*.xml", System.IO.SearchOption.TopDirectoryOnly);
foreach (var xmlFile in xmlCommentFiles)
{
//includeControllerXmlComments参数:是否启用控制器上的xml注释
diff --git a/SwaggerStudy/Startup031.cs b/SwaggerStudy/Startup031.cs
index 8aae380..f187fc3 100644
--- a/SwaggerStudy/Startup031.cs
+++ b/SwaggerStudy/Startup031.cs
@@ -65,7 +65,8 @@ namespace SwaggerStudy
#endregion
#region 包含xml注释
- var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"SwaggerStudy*.xml", System.IO.SearchOption.TopDirectoryOnly);
+ //var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"SwaggerStudy*.xml", System.IO.SearchOption.TopDirectoryOnly);
+ var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}*.xml", System.IO.SearchOption.TopDirectoryOnly);
foreach (var xmlFile in xmlCommentFiles)
{
//includeControllerXmlComments参数:是否启用控制器上的xml注释
diff --git a/SwaggerStudy/Startup032.cs b/SwaggerStudy/Startup032.cs
index 2e1cbae..589426a 100644
--- a/SwaggerStudy/Startup032.cs
+++ b/SwaggerStudy/Startup032.cs
@@ -19,6 +19,7 @@ using Swashbuckle.AspNetCore.SwaggerUI;
using SwaggerStudy.Services;
using Microsoft.OpenApi.Models;
+using System.Reflection;
namespace SwaggerStudy
{
@@ -61,7 +62,8 @@ namespace SwaggerStudy
#endregion
#region 包含xml注释
- var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"SwaggerStudy*.xml", System.IO.SearchOption.TopDirectoryOnly);
+ //var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"SwaggerStudy*.xml", System.IO.SearchOption.TopDirectoryOnly);
+ var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}*.xml", System.IO.SearchOption.TopDirectoryOnly);
foreach (var xmlFile in xmlCommentFiles)
{
//includeControllerXmlComments参数:是否启用控制器上的xml注释
diff --git a/SwaggerStudy/StartupTest.cs b/SwaggerStudy/StartupTest.cs
index 4963f48..d522260 100644
--- a/SwaggerStudy/StartupTest.cs
+++ b/SwaggerStudy/StartupTest.cs
@@ -22,6 +22,7 @@ using Swashbuckle.AspNetCore.SwaggerGen;
using Swashbuckle.AspNetCore.SwaggerUI;
using SwaggerStudy.Services;
+using System.Reflection;
namespace SwaggerStudy
{
@@ -93,7 +94,8 @@ namespace SwaggerStudy
});
//包含xml注释
- var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"SwaggerStudy*.xml", System.IO.SearchOption.TopDirectoryOnly);
+ //var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"SwaggerStudy*.xml", System.IO.SearchOption.TopDirectoryOnly);
+ var xmlCommentFiles = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}*.xml", System.IO.SearchOption.TopDirectoryOnly);
foreach (var xmlFile in xmlCommentFiles)
{
setup.IncludeXmlComments(xmlFile, true);
@@ -120,7 +122,7 @@ namespace SwaggerStudy
//配置SwaggerGen
services.ConfigureSwaggerGen(setup =>
{
-
+
});
services.AddTransient();
@@ -160,6 +162,7 @@ namespace SwaggerStudy
setup.DisplayRequestDuration();
setup.ShowCommonExtensions();
setup.ShowExtensions();
+ setup.DocumentTitle = "Swagger 在线文档";
//swagger 访问页面前缀:默认swagger
//SwaggerUi首页地址:baseUrl+前辍+index.html 默认:/swagger/index.html
diff --git a/SwaggerStudy/SwaggerStudy.csproj b/SwaggerStudy/SwaggerStudy.csproj
index 166c388..fb313ce 100644
--- a/SwaggerStudy/SwaggerStudy.csproj
+++ b/SwaggerStudy/SwaggerStudy.csproj
@@ -18,8 +18,4 @@
-
-
-
-