11{ {> partial_header} }
22
33using System;
4- using Newtonsoft .Json;
5- using Newtonsoft .Json.Serialization;
4+ using System.Text .Json;
5+ using System.Text .Json.Serialization;
66
77namespace { {packageName} }.{ {modelPackage} }
88{
@@ -14,35 +14,28 @@ namespace {{packageName}}.{{modelPackage}}
1414 /// < summary>
1515 /// Custom JSON serializer
1616 /// < /summary>
17- public static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
17+ public static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions
1818 {
19- // OpenAPI generated types generally hide default constructors.
20- ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
21- MissingMemberHandling = MissingMemberHandling.Error,
22- ContractResolver = new DefaultContractResolver
23- {
24- NamingStrategy = new CamelCaseNamingStrategy
25- {
26- OverrideSpecifiedNames = false
27- }
28- }
19+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
20+ PropertyNameCaseInsensitive = false ,
21+ // To ignore comments or trailing commas, set these:
22+ ReadCommentHandling = JsonCommentHandling.Disallow,
23+ UnmappedMemberHandling = JsonUnmappedMemberHandling.Disallow,
24+ AllowTrailingCommas = false ,
2925 } ;
3026
27+
3128 /// <summary >
32- /// Custom JSON serializer for objects with additional properties
29+ /// Custom JSON serializer options for objects with additional properties.
3330 /// </summary >
34- public static readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings
31+ public static readonly JsonSerializerOptions AdditionalPropertiesSerializerOptions = new JsonSerializerOptions
3532 {
36- // OpenAPI generated types generally hide default constructors.
37- ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
38- MissingMemberHandling = MissingMemberHandling.Ignore,
39- ContractResolver = new DefaultContractResolver
40- {
41- NamingStrategy = new CamelCaseNamingStrategy
42- {
43- OverrideSpecifiedNames = false
44- }
45- }
33+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
34+ PropertyNameCaseInsensitive = false ,
35+
36+ ReadCommentHandling = JsonCommentHandling.Disallow,
37+ AllowTrailingCommas = false ,
38+
4639 } ;
4740
4841 /// <summary >
0 commit comments