update samples

This commit is contained in:
William Cheng
2020-11-26 18:44:18 +08:00
parent c950384a5d
commit 9334909bcd

View File

@@ -165,6 +165,23 @@ namespace Org.OpenAPITools.Client
{
private readonly String _baseUrl;
/// <summary>
/// Specifies the settings on a <see cref="JsonSerializer" /> object.
/// These settings can be adjusted to accomodate custom serialization rules.
/// </summary>
public JsonSerializerSettings SerializerSettings { get; set; } = new JsonSerializerSettings
{
// OpenAPI generated types generally hide default constructors.
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
OverrideSpecifiedNames = false
}
}
};
/// <summary>
/// Allows for extending request processing for <see cref="ApiClient"/> generated code.
/// </summary>
@@ -263,7 +280,7 @@ namespace Org.OpenAPITools.Client
RestRequest request = new RestRequest(Method(method))
{
Resource = path,
JsonSerializer = new CustomJsonCodec(configuration)
JsonSerializer = new CustomJsonCodec(SerializerSettings, configuration)
};
if (options.PathParameters != null)
@@ -411,7 +428,7 @@ namespace Org.OpenAPITools.Client
}
else
{
var customDeserializer = new CustomJsonCodec(configuration);
var customDeserializer = new CustomJsonCodec(SerializerSettings, configuration);
client.AddHandler("application/json", () => customDeserializer);
client.AddHandler("text/json", () => customDeserializer);
client.AddHandler("text/x-json", () => customDeserializer);
@@ -513,7 +530,7 @@ namespace Org.OpenAPITools.Client
}
else
{
var customDeserializer = new CustomJsonCodec(configuration);
var customDeserializer = new CustomJsonCodec(SerializerSettings, configuration);
client.AddHandler("application/json", () => customDeserializer);
client.AddHandler("text/json", () => customDeserializer);
client.AddHandler("text/x-json", () => customDeserializer);