aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs
diff options
context:
space:
mode:
authorBaronGreenback <jimcartlidge@yahoo.co.uk>2021-04-20 18:10:38 +0100
committerGitHub <noreply@github.com>2021-04-20 18:10:38 +0100
commitf8b717e7c51a771b937312af3f1aa77e044b86ce (patch)
tree1de949627db1b7b033ea47e34ae5d7e2a8a70bd3 /tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs
parent7848ea148438baf8929e1c2939e6979cb84aad1a (diff)
parent5a6e60b414046c274330479f7dfb9713eea20020 (diff)
Merge branch 'master' into ProfileMatch
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs')
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs b/tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs
new file mode 100644
index 000000000..0ade345a1
--- /dev/null
+++ b/tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs
@@ -0,0 +1,40 @@
+using System.IO;
+using System.Reflection;
+using System.Threading.Tasks;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Jellyfin.Server.Integration.Tests
+{
+ public sealed class OpenApiSpecTests : IClassFixture<JellyfinApplicationFactory>
+ {
+ private readonly JellyfinApplicationFactory _factory;
+ private readonly ITestOutputHelper _outputHelper;
+
+ public OpenApiSpecTests(JellyfinApplicationFactory factory, ITestOutputHelper outputHelper)
+ {
+ _factory = factory;
+ _outputHelper = outputHelper;
+ }
+
+ [Fact]
+ public async Task GetSpec_ReturnsCorrectResponse()
+ {
+ // Arrange
+ var client = _factory.CreateClient();
+
+ // Act
+ var response = await client.GetAsync("/api-docs/openapi.json");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType?.ToString());
+
+ // Write out for publishing
+ var responseBody = await response.Content.ReadAsStringAsync();
+ string outputPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "openapi.json"));
+ _outputHelper.WriteLine("Writing OpenAPI Spec JSON to '{0}'.", outputPath);
+ File.WriteAllText(outputPath, responseBody);
+ }
+ }
+}