mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 08:00:19 +01:00
Adds configuration option for swagger UI
- Config version to 2.1.0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
@@ -24,7 +24,7 @@ namespace Tgstation.Server.Host.Configuration
|
||||
/// <summary>
|
||||
/// The current <see cref="ConfigVersion"/>.
|
||||
/// </summary>
|
||||
public static readonly Version CurrentConfigVersion = new Version(2, 0, 0);
|
||||
public static readonly Version CurrentConfigVersion = new Version(2, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// The default value for <see cref="ServerInformation.MinimumPasswordLength"/>.
|
||||
@@ -87,6 +87,11 @@ namespace Tgstation.Server.Host.Configuration
|
||||
/// </summary>
|
||||
public bool UseBasicWatchdog { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If the swagger UI should be made avaiable.
|
||||
/// </summary>
|
||||
public bool HostApiDocumemtation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GeneralConfiguration"/> <see langword="class"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -394,7 +394,8 @@ namespace Tgstation.Server.Host.Core
|
||||
// suppress OperationCancelledExceptions, they are just aborted HTTP requests
|
||||
applicationBuilder.UseCancelledRequestSuppression();
|
||||
|
||||
if (hostingEnvironment.IsDevelopment())
|
||||
if (hostingEnvironment.IsDevelopment()
|
||||
|| generalConfiguration.HostApiDocumemtation)
|
||||
{
|
||||
applicationBuilder.UseSwagger();
|
||||
applicationBuilder.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TGS API V4"));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
@@ -613,6 +613,8 @@ namespace Tgstation.Server.Host.Setup
|
||||
if (String.IsNullOrWhiteSpace(newGeneralConfiguration.GitHubAccessToken))
|
||||
newGeneralConfiguration.GitHubAccessToken = null;
|
||||
|
||||
newGeneralConfiguration.HostApiDocumemtation = await PromptYesNo("Host API Documentation? (y/n): ", cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return newGeneralConfiguration;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"General": {
|
||||
"MinimumPasswordLength": 15,
|
||||
"GitHubAccessToken": null,
|
||||
@@ -9,7 +9,8 @@
|
||||
"UseBasicWatchdog": false,
|
||||
"UserLimit": 100,
|
||||
"InstanceLimit": 10,
|
||||
"ValidInstancePaths": null
|
||||
"ValidInstancePaths": null,
|
||||
"HostApiDocumemtation": false
|
||||
},
|
||||
"FileLogging": {
|
||||
"Directory": null,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
@@ -144,6 +144,7 @@ namespace Tgstation.Server.Host.Setup.Tests
|
||||
"-27",
|
||||
"5000",
|
||||
"fake token",
|
||||
"y",
|
||||
//logging config
|
||||
"no",
|
||||
//cp config
|
||||
@@ -166,6 +167,7 @@ namespace Tgstation.Server.Host.Setup.Tests
|
||||
String.Empty,
|
||||
String.Empty,
|
||||
"n",
|
||||
"n",
|
||||
//logging config
|
||||
"y",
|
||||
"not actually verified because lol mocks /../!@#$%^&*()/..///.",
|
||||
@@ -189,6 +191,7 @@ namespace Tgstation.Server.Host.Setup.Tests
|
||||
String.Empty,
|
||||
String.Empty,
|
||||
"y",
|
||||
"y",
|
||||
"will faile",
|
||||
String.Empty,
|
||||
String.Empty,
|
||||
|
||||
Reference in New Issue
Block a user