diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml
index 3a5e143e6b..123c939f48 100644
--- a/.github/workflows/ci-pipeline.yml
+++ b/.github/workflows/ci-pipeline.yml
@@ -478,7 +478,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: openapi-spec
- path: C:/swagger.json
+ path: C:/tgs_api.json
- name: Package Server Service
if: ${{ matrix.configuration == 'Release' && matrix.watchdog-type == 'Basic' }}
@@ -706,7 +706,7 @@ jobs:
path: ./swagger
- name: Lint OpenAPI Spec
- run: npx lint-openapi -v -p -c build/OpenApiValidationSettings.json ./swagger/swagger.json
+ run: npx lint-openapi -v -p -c build/OpenApiValidationSettings.json ./swagger/tgs_api.json
upload-code-coverage:
name: Upload Code Coverage
@@ -1311,7 +1311,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: ./swagger/swagger.json
+ asset_path: ./swagger/tgs_api.json
asset_name: swagger.json
asset_content_type: application/json
@@ -1615,7 +1615,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: ./swagger/swagger.json
+ asset_path: ./swagger/tgs_api.json
asset_name: swagger.json
asset_content_type: application/json
diff --git a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs
index 7b02f6d177..1bb02a86e6 100644
--- a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs
+++ b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs
@@ -108,7 +108,7 @@ namespace Tgstation.Server.Host.Configuration
public bool UseBasicWatchdog { get; set; }
///
- /// If the swagger UI should be made avaiable.
+ /// If the swagger documentation and UI should be made avaiable.
///
public bool HostApiDocumentation { get; set; }
diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs
index d730b9de10..4d54a42b01 100644
--- a/src/Tgstation.Server.Host/Core/Application.cs
+++ b/src/Tgstation.Server.Host/Core/Application.cs
@@ -471,8 +471,15 @@ namespace Tgstation.Server.Host.Core
if (generalConfiguration.HostApiDocumentation)
{
- applicationBuilder.UseSwagger();
- applicationBuilder.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TGS API"));
+ applicationBuilder.UseSwagger(options =>
+ {
+ options.RouteTemplate = Routes.Root + "doc/{documentName}.{json|yaml}";
+ });
+ applicationBuilder.UseSwaggerUI(options =>
+ {
+ options.RoutePrefix = "documentation";
+ options.SwaggerEndpoint(Routes.Root + $"doc/{SwaggerConfiguration.DocumentName}.json", "TGS API");
+ });
logger.LogTrace("Swagger API generation enabled");
}
diff --git a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs
index 89f7716732..927fc4f4fa 100644
--- a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs
+++ b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs
@@ -27,6 +27,11 @@ namespace Tgstation.Server.Host.Utils
///
sealed class SwaggerConfiguration : IOperationFilter, IDocumentFilter, ISchemaFilter, IRequestBodyFilter
{
+ ///
+ /// The name of the swagger document.
+ ///
+ public const string DocumentName = "tgs_api";
+
///
/// The name for password authentication.
///
@@ -51,7 +56,7 @@ namespace Tgstation.Server.Host.Utils
public static void Configure(SwaggerGenOptions swaggerGenOptions, string assemblyDocumentationPath, string apiDocumentationPath)
{
swaggerGenOptions.SwaggerDoc(
- "v1",
+ DocumentName,
new OpenApiInfo
{
Title = "TGS API",
diff --git a/src/Tgstation.Server.Host/appsettings.yml b/src/Tgstation.Server.Host/appsettings.yml
index bebeb79c04..680c347e3d 100644
--- a/src/Tgstation.Server.Host/appsettings.yml
+++ b/src/Tgstation.Server.Host/appsettings.yml
@@ -13,7 +13,7 @@ General:
UserGroupLimit: 25 # Maximum number of allowed groups
InstanceLimit: 10 # Maximum number of allowed instances
ValidInstancePaths: # An array of directories instances may be created in (either directly or as a subdirectory). null removes the restriction
- HostApiDocumentation: false # Make HTTP API documentation available at /swagger/v1/swagger.json
+ HostApiDocumentation: false # Make HTTP API documentation available at /doc/tgs_api.json
SkipAddingByondFirewallException: false # Windows Only: Prevent running netsh.exe to add a firewall exception for installed DreamDaemon binaries
DeploymentDirectoryCopyTasksPerCore: 100 # Maximum number of concurrent file copy operations PER available CPU core
Session:
diff --git a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs
index 0ef060c2f3..f8cf0c7802 100644
--- a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs
+++ b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs
@@ -1302,11 +1302,11 @@ namespace Tgstation.Server.Tests.Live
// Dump swagger to disk
// This is purely for CI
using var httpClient = new HttpClient();
- var webRequestTask = httpClient.GetAsync(server.Url.ToString() + "swagger/v1/swagger.json", cancellationToken);
+ var webRequestTask = httpClient.GetAsync(server.Url.ToString() + "doc/tgs_api.json", cancellationToken);
using var response = await webRequestTask;
response.EnsureSuccessStatusCode();
await using var content = await response.Content.ReadAsStreamAsync(cancellationToken);
- await using var output = new FileStream(@"C:\swagger.json", FileMode.Create);
+ await using var output = new FileStream(@"C:\tgs_api.json", FileMode.Create);
await content.CopyToAsync(output, cancellationToken);
}