mirror of
https://github.com/BlossomiShymae/Needlework.Net.git
synced 2026-07-11 21:49:42 +02:00
feat: add schema search pane
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user