21 lines
632 B
C#
21 lines
632 B
C#
using EonaCat.DoxaApi.Models;
|
|
using System.Text.Json;
|
|
|
|
namespace EonaCat.DoxaApi.Interop
|
|
{
|
|
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.");
|
|
}
|
|
}
|
|
}
|