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,137 @@
#nullable enable
#pragma warning disable CS0618 // Type or member is obsolete

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public class CodeInterpreterCallItemOutputsItemsJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.CodeInterpreterCallItemOutputsItems>
{
/// <inheritdoc />
public override global::OpenRouter.CodeInterpreterCallItemOutputsItems Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");

using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader);
var __rawJson = __jsonDocument.RootElement.GetRawText();
var __jsonProps = new global::System.Collections.Generic.HashSet<string>();
if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object)
{
foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject())
{
__jsonProps.Add(__jsonProp.Name);
}
}

var __score0 = 0;
if (__jsonProps.Contains("type")) __score0++;
if (__jsonProps.Contains("url")) __score0++;
var __score1 = 0;
if (__jsonProps.Contains("logs")) __score1++;
if (__jsonProps.Contains("type")) __score1++;
var __bestScore = 0;
var __bestIndex = -1;
if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; }
if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; }

global::OpenRouter.CodeInterpreterCallItemOutputsItems0? codeInterpreterCallItemOutputsItems0 = default;
global::OpenRouter.CodeInterpreterCallItemOutputsItems1? codeInterpreterCallItemOutputsItems1 = default;
if (__bestIndex >= 0)
{
if (__bestIndex == 0)
{
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.CodeInterpreterCallItemOutputsItems0), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.CodeInterpreterCallItemOutputsItems0> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.CodeInterpreterCallItemOutputsItems0).Name}");
codeInterpreterCallItemOutputsItems0 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}
}
else if (__bestIndex == 1)
{
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.CodeInterpreterCallItemOutputsItems1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.CodeInterpreterCallItemOutputsItems1> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.CodeInterpreterCallItemOutputsItems1).Name}");
codeInterpreterCallItemOutputsItems1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}
}
}

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

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

var __value = new global::OpenRouter.CodeInterpreterCallItemOutputsItems(
codeInterpreterCallItemOutputsItems0,

codeInterpreterCallItemOutputsItems1
);

return __value;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.CodeInterpreterCallItemOutputsItems value,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");

if (value.IsCodeInterpreterCallItemOutputsItems0)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.CodeInterpreterCallItemOutputsItems0), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.CodeInterpreterCallItemOutputsItems0?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.CodeInterpreterCallItemOutputsItems0).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.CodeInterpreterCallItemOutputsItems0!, typeInfo);
}
else if (value.IsCodeInterpreterCallItemOutputsItems1)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenRouter.CodeInterpreterCallItemOutputsItems1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenRouter.CodeInterpreterCallItemOutputsItems1?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenRouter.CodeInterpreterCallItemOutputsItems1).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.CodeInterpreterCallItemOutputsItems1!, typeInfo);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

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

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

return default;
}

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

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

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class CodeInterpreterCallItemOutputsItemsOneOf0TypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf0Type?>
{
/// <inheritdoc />
public override global::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf0Type? 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::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf0TypeExtensions.ToEnum(stringValue);
}

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

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf0Type? 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::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf0TypeExtensions.ToValueString(value.Value));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

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

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

return default;
}

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

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

namespace OpenRouter.JsonConverters
{
/// <inheritdoc />
public sealed class CodeInterpreterCallItemOutputsItemsOneOf1TypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf1Type?>
{
/// <inheritdoc />
public override global::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf1Type? 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::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf1TypeExtensions.ToEnum(stringValue);
}

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

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf1Type? 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::OpenRouter.CodeInterpreterCallItemOutputsItemsOneOf1TypeExtensions.ToValueString(value.Value));
}
}
}
}
Loading
Loading