Initial version
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user