feat: add schema search pane

This commit is contained in:
estrogen elf
2025-06-15 14:00:58 -05:00
parent b74437d05e
commit cbc3c42116
14 changed files with 650 additions and 295 deletions
+5 -4
View File
@@ -5,6 +5,7 @@ using Microsoft.OpenApi.Readers;
using Needlework.Net.Extensions;
using Needlework.Net.Models;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Needlework.Net
@@ -20,7 +21,7 @@ namespace Needlework.Net
_githubUserContentClient = clients.Get("GithubUserContentClient");
}
public async Task<Document> GetLcuSchemaDocumentAsync()
public async Task<Document> GetLcuSchemaDocumentAsync(CancellationToken cancellationToken = default)
{
if (Cached<Document>.TryGet(nameof(GetLcuSchemaDocumentAsync), out var cached))
{
@@ -28,14 +29,14 @@ namespace Needlework.Net
}
var lcuSchemaStream = await _githubUserContentClient.Request("/dysolix/hasagi-types/main/swagger.json")
.GetStreamAsync();
.GetStreamAsync(cancellationToken: cancellationToken);
var lcuSchemaRaw = _reader.Read(lcuSchemaStream, out var _);
var document = new Document(lcuSchemaRaw);
return cached.Save(document, TimeSpan.FromMinutes(60));
}
public async Task<Document> GetLolClientDocumentAsync()
public async Task<Document> GetLolClientDocumentAsync(CancellationToken cancellationToken = default)
{
if (Cached<Document>.TryGet(nameof(GetLolClientDocumentAsync), out var cached))
{
@@ -43,7 +44,7 @@ namespace Needlework.Net
}
var lolClientStream = await _githubUserContentClient.Request("/AlsoSylv/Irelia/refs/heads/master/schemas/game_schema.json")
.GetStreamAsync();
.GetStreamAsync(cancellationToken: cancellationToken);
var lolClientRaw = _reader.Read(lolClientStream, out var _);
var document = new Document(lolClientRaw);