From 599dfcc071816ba4ac8b95e225a9c05ce08d122b Mon Sep 17 00:00:00 2001 From: Ske Date: Thu, 7 May 2020 06:09:55 +0200 Subject: [PATCH] Enable XML comment support for Swashbuckle --- PluralKit.API/PluralKit.API.csproj | 8 +++++++- PluralKit.API/Startup.cs | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/PluralKit.API/PluralKit.API.csproj b/PluralKit.API/PluralKit.API.csproj index 3f9e60f5..d36e8fd2 100644 --- a/PluralKit.API/PluralKit.API.csproj +++ b/PluralKit.API/PluralKit.API.csproj @@ -1,9 +1,15 @@ - + netcoreapp3.1 + + + true + $(NoWarn);1591 + + diff --git a/PluralKit.API/Startup.cs b/PluralKit.API/Startup.cs index 05a2b0d5..5f6b3c94 100644 --- a/PluralKit.API/Startup.cs +++ b/PluralKit.API/Startup.cs @@ -1,4 +1,6 @@ -using System; +using System; +using System.IO; +using System.Reflection; using Autofac; @@ -60,6 +62,12 @@ namespace PluralKit.API if (!apiDesc.RelativePath.StartsWith("v1/")) return false; return apiDesc.GroupName == docName; }); + + // Set the comments path for the Swagger JSON and UI. + // https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1&tabs=visual-studio#customize-and-extend + var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); + c.IncludeXmlComments(xmlPath); }); services.AddSwaggerGenNewtonsoftSupport(); }