oprava konvertoru

This commit is contained in:
JiriUhlir
2026-08-25 08:53:52 +02:00
parent d9e3c59d69
commit 2f3afb6af0
5 changed files with 192 additions and 1 deletions
+13
View File
@@ -1,5 +1,6 @@
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Idoklad.Client;
using Idoklad.Configuration;
using Idoklad.Credentials;
@@ -47,6 +48,18 @@ builder.Services
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
// Some IdokladSdk converters attached to model members only support reading (their
// WriteJson throws NotImplementedException), which makes responses carrying such models
// fail. The resolver bypasses them on the write path; the existing naming strategy is
// preserved so property names in responses do not change.
var contractResolver = new SdkContractResolver();
if (options.SerializerSettings.ContractResolver is DefaultContractResolver defaultResolver)
{
contractResolver.NamingStrategy = defaultResolver.NamingStrategy;
}
options.SerializerSettings.ContractResolver = contractResolver;
});
builder.Services.AddEndpointsApiExplorer();