using EonaCat.DoxaApi.Models; using EonaCat.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 JsonHelper.ToObject(json) ?? throw new InvalidOperationException("Invalid DoxaApi spec."); } public static async Task ImportAsync(Stream stream) { using var reader = new StreamReader(stream); var json = await reader.ReadToEndAsync(); var doc = JsonHelper.ToObject(json); return doc ?? throw new InvalidOperationException("Invalid DoxaApi spec."); } } }