revize endpointu: cteni NullableProperty, filtr v UTC, attachments
Kontrola vsech 180 operaci proti falesnemu iDoklad API a round trip 331 modelu SDK v obou smerech. - SdkNullablePropertyConverter doplnuje cteni NullableProperty<T>. Konvertor SDK umi jen zapis, takze PATCH s takovou polozkou koncil prazdnou 500 uz pri cteni tela. Tykalo se 29 modelu. Zapis zustava na konvertoru SDK, odchozi payload se nemeni. - Datum uvnitr NullableProperty se normalizuje na UTC stejne jako zbytek serializace. - ListModifiers parsuje datum ve filtru s AdjustToUniversal a AssumeUniversal. Filtr se zonou se drive posouval o offset. - POST /attachments kontroluje FileName a FileBytes, SDK na ne sahalo bez kontroly na null a vracelo neosetrenou 500. - ExceptionHandlingMiddleware ma posledni zachyt, zadny request uz nekonci prazdnou 500. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
73f01d0228
commit
225161e4ca
@@ -5,18 +5,17 @@ using Newtonsoft.Json.Serialization;
|
||||
namespace Idoklad.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
/// Makes iDoklad SDK models serializable. Some SDK converters, attached through
|
||||
/// <see cref="JsonConverterAttribute"/>, only support reading and their <c>WriteJson</c> throws
|
||||
/// <see cref="NotImplementedException"/>, which turns any response carrying such a model into a
|
||||
/// 500. This resolver replaces them with <see cref="SdkWriteBypassJsonConverter"/>: reading keeps
|
||||
/// using the SDK converter, writing falls back to the standard serialization. Everything else is
|
||||
/// Makes iDoklad SDK models usable in both directions. The SDK only ever serializes what it sends
|
||||
/// and deserializes what it receives, so several of its converters, attached through
|
||||
/// <see cref="JsonConverterAttribute"/>, implement one direction and throw
|
||||
/// <see cref="NotImplementedException"/> in the other. This service needs both directions, so this
|
||||
/// resolver swaps those converters for wrappers that fill in the missing half. Everything else is
|
||||
/// left to <see cref="DefaultContractResolver"/>.
|
||||
/// </summary>
|
||||
public sealed class SdkContractResolver : DefaultContractResolver
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK converters that cannot write. Converters that do implement writing (for example
|
||||
/// <c>NullablePropertyJsonConverter</c>) are deliberately not listed here.
|
||||
/// SDK converters that cannot write, so responses carrying such a model would fail.
|
||||
/// </summary>
|
||||
private static readonly HashSet<string> WriteUnsupportedConverterTypeNames = new(StringComparer.Ordinal)
|
||||
{
|
||||
@@ -27,6 +26,11 @@ public sealed class SdkContractResolver : DefaultContractResolver
|
||||
"IdokladSdk.Serialization.NotificationJsonConverter",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// SDK converters that cannot read, so a request body carrying such a member would fail.
|
||||
/// </summary>
|
||||
private const string NullablePropertyConverterTypeName = "IdokladSdk.Clients.NullablePropertyJsonConverter";
|
||||
|
||||
protected override JsonContract CreateContract(Type objectType)
|
||||
{
|
||||
var contract = base.CreateContract(objectType);
|
||||
@@ -49,8 +53,19 @@ public sealed class SdkContractResolver : DefaultContractResolver
|
||||
{
|
||||
var typeName = converter?.GetType().FullName;
|
||||
|
||||
return typeName is not null && WriteUnsupportedConverterTypeNames.Contains(typeName)
|
||||
? new SdkWriteBypassJsonConverter(converter!)
|
||||
if (typeName is null)
|
||||
{
|
||||
return converter;
|
||||
}
|
||||
|
||||
if (WriteUnsupportedConverterTypeNames.Contains(typeName))
|
||||
{
|
||||
return new SdkWriteBypassJsonConverter(converter!);
|
||||
}
|
||||
|
||||
// Attached to NullableProperty<T> members of Patch models; writing works, reading throws.
|
||||
return typeName == NullablePropertyConverterTypeName
|
||||
? new SdkNullablePropertyConverter(converter!)
|
||||
: converter;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user