From 182f49d6b48f639d1c969d43be763555698ff9d3 Mon Sep 17 00:00:00 2001 From: lxw Date: Thu, 16 May 2024 13:45:57 +0800 Subject: [PATCH] =?UTF-8?q?swagger=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebStarter/Program.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index 0f9860c..d730f5f 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -43,6 +43,16 @@ builder.Services.AddCors(options => ); }); +builder.Services.AddSwaggerGen(c => +{ + string? basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location); //获取应用程序所在目录 + if (basePath != null) + { + string xmlPath = Path.Combine(basePath, "WebStarter.xml"); + c.IncludeXmlComments(xmlPath); + } +}); + builder.Services.AddControllers().AddJsonOptions(configure => { configure.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());