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
@@ -0,0 +1,53 @@
#nullable enable

namespace AssemblyAI.JsonConverters
{
/// <inheritdoc />
public sealed class ActionItemsRequestBodyActionItemsEffortJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.ActionItemsRequestBodyActionItemsEffort>
{
/// <inheritdoc />
public override global::AssemblyAI.ActionItemsRequestBodyActionItemsEffort 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.ActionItemsRequestBodyActionItemsEffortExtensions.ToEnum(stringValue) ?? default;
}

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

return default;
}

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

writer.WriteStringValue(global::AssemblyAI.ActionItemsRequestBodyActionItemsEffortExtensions.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 ActionItemsRequestBodyActionItemsEffortNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.ActionItemsRequestBodyActionItemsEffort?>
{
/// <inheritdoc />
public override global::AssemblyAI.ActionItemsRequestBodyActionItemsEffort? 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.ActionItemsRequestBodyActionItemsEffortExtensions.ToEnum(stringValue);
}

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

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::AssemblyAI.ActionItemsRequestBodyActionItemsEffort? 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.ActionItemsRequestBodyActionItemsEffortExtensions.ToValueString(value.Value));
}
}
}
}
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, T4> : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.OneOf<T1, T2, T3, T4>>
public class OneOfJsonConverter<T1, T2, T3, T4, T5> : global::System.Text.Json.Serialization.JsonConverter<global::AssemblyAI.OneOf<T1, T2, T3, T4, T5>>
{
/// <inheritdoc />
public override global::AssemblyAI.OneOf<T1, T2, T3, T4> Read(
public override global::AssemblyAI.OneOf<T1, T2, T3, T4, T5> Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand Down Expand Up @@ -70,17 +70,30 @@ public class OneOfJsonConverter<T1, T2, T3, T4> : global::System.Text.Json.Seria
}
}
}
var __score4 = 0;
{
var __ti = typeInfoResolver.GetTypeInfo(typeof(T5), 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)) __score4++;
}
}
}
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; }
if (__score4 > __bestScore) { __bestScore = __score4; __bestIndex = 4; }

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

else if (__bestIndex == 4)
{
try
{

var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T5), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T5> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T5).Name}");
value5 = 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 && value4 == null)
if (value1 == null && value2 == null && value3 == null && value4 == null && value5 == null)
{
try
{
Expand All @@ -169,7 +199,7 @@ public class OneOfJsonConverter<T1, T2, T3, T4> : global::System.Text.Json.Seria
}
}

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

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

if (value1 == null && value2 == null && value3 == null && value4 == null)
if (value1 == null && value2 == null && value3 == null && value4 == null && value5 == null)
{
try
{
Expand All @@ -220,14 +250,33 @@ public class OneOfJsonConverter<T1, T2, T3, T4> : global::System.Text.Json.Seria
}
}

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

var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T5), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T5> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T5).Name}");
value5 = 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, T5>(
value1,

value2,

value3,

value4
value4,

value5
);

return __value;
Expand All @@ -236,7 +285,7 @@ public class OneOfJsonConverter<T1, T2, T3, T4> : global::System.Text.Json.Seria
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::AssemblyAI.OneOf<T1, T2, T3, T4> value,
global::AssemblyAI.OneOf<T1, T2, T3, T4, T5> value,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
Expand Down Expand Up @@ -266,6 +315,12 @@ public override void Write(
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T4).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value4!, typeInfo);
}
else if (value.IsValue5)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T5), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T5?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T5).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value5!, typeInfo);
}
}
}
}
Loading