Files
EonaCat.DoxaApi/DoxaApi/Importer/ApiDocsImporter.cs
T
2026-06-21 20:10:02 +02:00

24 lines
819 B
C#

using EonaCat.DoxaApi.Models;
using System.Text.Json;
namespace EonaCat.DoxaApi.Interop
{
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/license for full license details.
public static class DoxaApiImporter
{
public static ApiDocument Import(string json)
{
return JsonSerializer.Deserialize<ApiDocument>(json)
?? throw new InvalidOperationException("Invalid DoxaApi spec.");
}
public static async Task<ApiDocument> ImportAsync(Stream stream)
{
var doc = await JsonSerializer.DeserializeAsync<ApiDocument>(stream);
return doc ?? throw new InvalidOperationException("Invalid DoxaApi spec.");
}
}
}