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