From 5d20fa76c0cbd5c066e3e84a3e104a67f9253683 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 3 Nov 2020 11:35:34 -0500 Subject: [PATCH] Fix hosting API documentation in production - Actually inject the swagger service if the config is set. - This setting is no longer overridden by launching in development mode. --- src/Tgstation.Server.Host/Core/Application.cs | 5 ++--- tests/Tgstation.Server.Tests/TestingServer.cs | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index b1dc85fcee..dc235d3140 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -195,7 +195,7 @@ namespace Tgstation.Server.Host.Core options.SerializerSettings.Converters = new[] { new VersionConverter() }; }); - if (hostingEnvironment.IsDevelopment()) + if (postSetupServices.GeneralConfiguration.HostApiDocumemtation) { static string GetDocumentationFilePath(string assemblyLocation) => IOManager.ConcatPath(IOManager.GetDirectoryName(assemblyLocation), String.Concat(IOManager.GetFileNameWithoutExtension(assemblyLocation), ".xml")); var assemblyDocumentationPath = GetDocumentationFilePath(typeof(Application).Assembly.Location); @@ -396,8 +396,7 @@ namespace Tgstation.Server.Host.Core // suppress OperationCancelledExceptions, they are just aborted HTTP requests applicationBuilder.UseCancelledRequestSuppression(); - if (hostingEnvironment.IsDevelopment() - || generalConfiguration.HostApiDocumemtation) + if (generalConfiguration.HostApiDocumemtation) { applicationBuilder.UseSwagger(); applicationBuilder.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TGS API V4")); diff --git a/tests/Tgstation.Server.Tests/TestingServer.cs b/tests/Tgstation.Server.Tests/TestingServer.cs index c061a0f9f3..a3181cf3cc 100644 --- a/tests/Tgstation.Server.Tests/TestingServer.cs +++ b/tests/Tgstation.Server.Tests/TestingServer.cs @@ -78,6 +78,7 @@ namespace Tgstation.Server.Tests String.Format(CultureInfo.InvariantCulture, "General:MinimumPasswordLength={0}", 10), String.Format(CultureInfo.InvariantCulture, "General:InstanceLimit={0}", 11), String.Format(CultureInfo.InvariantCulture, "General:UserLimit={0}", 150), + String.Format(CultureInfo.InvariantCulture, "General:HostApiDocumentation={0}", DumpOpenApiSpecpath), String.Format(CultureInfo.InvariantCulture, "FileLogging:Directory={0}", Path.Combine(Directory, "Logs")), String.Format(CultureInfo.InvariantCulture, "FileLogging:LogLevel={0}", "Trace"), String.Format(CultureInfo.InvariantCulture, "General:ValidInstancePaths:0={0}", Directory),