PrivaPub's own types are read through the shared ClientModels context, and a type without generated metadata no longer falls back to reflection silently: it fails at once in development and on the pasture, and is reported on the console elsewhere. Startup outside production checks that every PrivaPub and Mastodon type the client knows has its metadata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
This commit is contained in:
1 parent
3bc511421e
commit
dca046e27d
6 files changed
+70
-105
No files matched your search
+3
-4
@@ -2,7 +2,6 @@
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
|
||||
using decePubClient.Models;
|
||||
using decePubClient.Services;
|
||||
@@ -22,13 +21,13 @@ namespace decePubClient.Helpers
|
||||
|
||||
/// <summary>
|
||||
/// The JSON options for /clientapi payloads and localStorage: web defaults, enums by name as PrivaPub writes them
|
||||
/// (numbers still read), ClientJsonContext first, reflection after.
|
||||
/// (numbers still read), ClientJsonContext first, then PrivaPub.ClientModels' own context.
|
||||
/// </summary>
|
||||
public static JsonSerializerOptions DefaultSerializer { get; } = new(JsonSerializerDefaults.Web)
|
||||
{
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
Converters = { new JsonStringEnumConverter() },
|
||||
TypeInfoResolver = JsonTypeInfoResolver.Combine(ClientJsonContext.Default, new DefaultJsonTypeInfoResolver())
|
||||
TypeInfoResolverChain = { ClientJsonContext.Default, ClientModelsJsonContext.Default, UnregisteredJson.Instance }
|
||||
};
|
||||
|
||||
/// <summary>The JSON options for PrivaPub's Mastodon API and /oauth: snake_case, MastodonJsonContext first.</summary>
|
||||
@@ -37,7 +36,7 @@ namespace decePubClient.Helpers
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
IgnoreReadOnlyProperties = true,
|
||||
TypeInfoResolver = JsonTypeInfoResolver.Combine(MastodonJsonContext.Default, new DefaultJsonTypeInfoResolver())
|
||||
TypeInfoResolverChain = { MastodonJsonContext.Default, UnregisteredJson.Instance }
|
||||
};
|
||||
|
||||
/// <summary>What a cancelled request turns into: HTTP 410, which AddResponseError ignores.</summary>
|
||||
|
||||
Reference in new issue
Block a user