using System.Net;
using System.Text.Json;

namespace Tiku.IntegrationTests.Api;

public sealed class OpenApiDocumentationTests
{
    [Fact]
    public async Task Openapi_document_can_be_generated_with_key_paths()
    {
        await using var factory = new ApiTestFactory();
        using var client = factory.CreateClient();

        using var response = await client.GetAsync("/openapi/v1.json");
        var document = JsonDocument.Parse(await response.Content.ReadAsStringAsync());

        Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        Assert.True(document.RootElement.GetProperty("paths").TryGetProperty("/api/auth/login/password", out _));
        Assert.True(document.RootElement.GetProperty("paths").TryGetProperty("/api/catalog/regions", out _));
    }
}
