oprava konvertoru
This commit is contained in:
+13
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user