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 @@ -17,105 +17,34 @@ public class PredictionListResponseJsonConverter : global::System.Text.Json.Seri

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);
if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object)
{
foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject())
{
__jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name);
}
}

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

var __score0 = 0;
if (__jsonProps.Contains("code")) __score0++;
if (__jsonProps.Contains("message")) __score0++;
var __score1 = 0;
if (__jsonProps.Contains("data")) __score1++;
if (__jsonProps.Contains("data.items")) __score1++;
if (__jsonProps.Contains("data.page")) __score1++;
var __bestScore = 0;
var __bestIndex = -1;
if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; }
if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; }

global::WaveSpeedAI.ApiResponse? api = default;
global::WaveSpeedAI.PredictionListResponseVariant2? predictionListResponseVariant2 = default;
if (__bestIndex >= 0)
try
{
if (__bestIndex == 0)
{
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::WaveSpeedAI.ApiResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::WaveSpeedAI.ApiResponse> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::WaveSpeedAI.ApiResponse).Name}");
api = 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::WaveSpeedAI.PredictionListResponseVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::WaveSpeedAI.PredictionListResponseVariant2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::WaveSpeedAI.PredictionListResponseVariant2).Name}");
predictionListResponseVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
}
catch (global::System.InvalidOperationException)
{
}
}
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::WaveSpeedAI.PredictionListResponseVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::WaveSpeedAI.PredictionListResponseVariant2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::WaveSpeedAI.PredictionListResponseVariant2).Name}");
predictionListResponseVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}

if (api == null && predictionListResponseVariant2 == null)
catch (global::System.Text.Json.JsonException)
{
try
{

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

if (api == null && predictionListResponseVariant2 == null)
catch (global::System.InvalidOperationException)
{
try
{

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

var __value = new global::WaveSpeedAI.PredictionListResponse(
api,

Expand All @@ -134,18 +63,46 @@ public override void Write(
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");


writer.WriteStartObject();
var __writtenPropertyNames = new global::System.Collections.Generic.HashSet<string>(global::System.StringComparer.Ordinal);
if (value.IsApi)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::WaveSpeedAI.ApiResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::WaveSpeedAI.ApiResponse?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::WaveSpeedAI.ApiResponse).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Api!, typeInfo);
var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Api!, typeInfo);
if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object)
{
throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects.");
}

foreach (var __property in __element0.EnumerateObject())
{
if (__writtenPropertyNames.Add(__property.Name))
{
__property.WriteTo(writer);
}
}
}
else if (value.IsPredictionListResponseVariant2)
if (value.IsPredictionListResponseVariant2)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::WaveSpeedAI.PredictionListResponseVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::WaveSpeedAI.PredictionListResponseVariant2?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::WaveSpeedAI.PredictionListResponseVariant2).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.PredictionListResponseVariant2!, typeInfo);
var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.PredictionListResponseVariant2!, typeInfo);
if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object)
{
throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects.");
}

foreach (var __property in __element1.EnumerateObject())
{
if (__writtenPropertyNames.Add(__property.Name))
{
__property.WriteTo(writer);
}
}
}
writer.WriteEndObject();
}
}
}
Loading