Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace AssemblyAI.JsonConverters
{
/// <inheritdoc />
public class OneOfJsonConverter<T1, T2, T3> : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.OneOf<T1, T2, T3>>
public class OneOfJsonConverter<T1, T2, T3, T4> : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.OneOf<T1, T2, T3, T4>>
{
/// <inheritdoc />
public override global::AssemblyAI.OneOf<T1, T2, T3> Read(
public override global::AssemblyAI.OneOf<T1, T2, T3, T4> Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand Down Expand Up @@ -59,15 +59,28 @@ public class OneOfJsonConverter<T1, T2, T3> : global::System.Text.Json.Serializa
}
}
}
var __score3 = 0;
{
var __ti = typeInfoResolver.GetTypeInfo(typeof(T4), options);
if (__ti != null && __ti.Kind == global::System.Text.Json.Serialization.Metadata.JsonTypeInfoKind.Object)
{
foreach (var __prop in __ti.Properties)
{
if (__jsonProps.Contains(__prop.Name)) __score3++;
}
}
}
var __bestScore = 0;
var __bestIndex = -1;
if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; }
if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; }
if (__score2 > __bestScore) { __bestScore = __score2; __bestIndex = 2; }
if (__score3 > __bestScore) { __bestScore = __score3; __bestIndex = 3; }

T1? value1 = default;
T2? value2 = default;
T3? value3 = default;
T4? value4 = default;
if (__bestIndex >= 0)
{
if (__bestIndex == 0)
Expand Down Expand Up @@ -120,9 +133,26 @@ public class OneOfJsonConverter<T1, T2, T3> : global::System.Text.Json.Serializa
{
}
}

else if (__bestIndex == 3)
{
try
{

var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T4), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T4> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T4).Name}");
value4 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}
}
}

if (value1 == null && value2 == null && value3 == null)
if (value1 == null && value2 == null && value3 == null && value4 == null)
{
try
{
Expand All @@ -139,7 +169,7 @@ public class OneOfJsonConverter<T1, T2, T3> : global::System.Text.Json.Serializa
}
}

if (value1 == null && value2 == null && value3 == null)
if (value1 == null && value2 == null && value3 == null && value4 == null)
{
try
{
Expand All @@ -156,7 +186,7 @@ public class OneOfJsonConverter<T1, T2, T3> : global::System.Text.Json.Serializa
}
}

if (value1 == null && value2 == null && value3 == null)
if (value1 == null && value2 == null && value3 == null && value4 == null)
{
try
{
Expand All @@ -173,12 +203,31 @@ public class OneOfJsonConverter<T1, T2, T3> : global::System.Text.Json.Serializa
}
}

var __value = new global::AssemblyAI.OneOf<T1, T2, T3>(
if (value1 == null && value2 == null && value3 == null && value4 == null)
{
try
{

var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T4), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T4> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T4).Name}");
value4 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}
}

var __value = new global::AssemblyAI.OneOf<T1, T2, T3, T4>(
value1,

value2,

value3
value3,

value4
);

return __value;
Expand All @@ -187,7 +236,7 @@ public class OneOfJsonConverter<T1, T2, T3> : global::System.Text.Json.Serializa
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::AssemblyAI.OneOf<T1, T2, T3> value,
global::AssemblyAI.OneOf<T1, T2, T3, T4> value,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
Expand All @@ -211,6 +260,12 @@ public override void Write(
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T3).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value3!, typeInfo);
}
else if (value.IsValue4)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T4), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T4?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T4).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value4!, typeInfo);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace AssemblyAI.JsonConverters
{
/// <inheritdoc />
public sealed class SummarizationRequestBodySummarizationEffortJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.SummarizationRequestBodySummarizationEffort>
{
/// <inheritdoc />
public override global::AssemblyAI.SummarizationRequestBodySummarizationEffort Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::AssemblyAI.SummarizationRequestBodySummarizationEffortExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::AssemblyAI.SummarizationRequestBodySummarizationEffort)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::AssemblyAI.SummarizationRequestBodySummarizationEffort);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::AssemblyAI.SummarizationRequestBodySummarizationEffort value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::AssemblyAI.SummarizationRequestBodySummarizationEffortExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#nullable enable

namespace AssemblyAI.JsonConverters
{
/// <inheritdoc />
public sealed class SummarizationRequestBodySummarizationEffortNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.SummarizationRequestBodySummarizationEffort?>
{
/// <inheritdoc />
public override global::AssemblyAI.SummarizationRequestBodySummarizationEffort? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::AssemblyAI.SummarizationRequestBodySummarizationEffortExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::AssemblyAI.SummarizationRequestBodySummarizationEffort)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::AssemblyAI.SummarizationRequestBodySummarizationEffort?);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::AssemblyAI.SummarizationRequestBodySummarizationEffort? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::AssemblyAI.SummarizationRequestBodySummarizationEffortExtensions.ToValueString(value.Value));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace AssemblyAI.JsonConverters
{
/// <inheritdoc />
public sealed class SummarizationRequestBodySummarizationSummaryTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType>
{
/// <inheritdoc />
public override global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::AssemblyAI.SummarizationRequestBodySummarizationSummaryTypeExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::AssemblyAI.SummarizationRequestBodySummarizationSummaryTypeExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#nullable enable

namespace AssemblyAI.JsonConverters
{
/// <inheritdoc />
public sealed class SummarizationRequestBodySummarizationSummaryTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType?>
{
/// <inheritdoc />
public override global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::AssemblyAI.SummarizationRequestBodySummarizationSummaryTypeExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType?);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::AssemblyAI.SummarizationRequestBodySummarizationSummaryType? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::AssemblyAI.SummarizationRequestBodySummarizationSummaryTypeExtensions.ToValueString(value.Value));
}
}
}
}
Loading