Added more security and metrics
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using EonaCat.DoxaApi.Models;
|
||||
using System.Text.Json;
|
||||
using EonaCat.Json;
|
||||
|
||||
namespace EonaCat.DoxaApi.Interop
|
||||
{
|
||||
@@ -10,13 +10,15 @@ namespace EonaCat.DoxaApi.Interop
|
||||
{
|
||||
public static ApiDocument Import(string json)
|
||||
{
|
||||
return JsonSerializer.Deserialize<ApiDocument>(json)
|
||||
return JsonHelper.ToObject<ApiDocument>(json)
|
||||
?? throw new InvalidOperationException("Invalid DoxaApi spec.");
|
||||
}
|
||||
|
||||
public static async Task<ApiDocument> ImportAsync(Stream stream)
|
||||
{
|
||||
var doc = await JsonSerializer.DeserializeAsync<ApiDocument>(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.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user