From d36155b7c04eae497aaaf888c8f9eb12158efba9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 29 Aug 2026 05:15:09 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- .../StabilityAI.JsonConverters.AllOf2.g.cs | 144 ++++++------------ ...eToImageUsingImageStrengthRequestBody.g.cs | 139 ++++++----------- ...geToImageUsingStepScheduleRequestBody.g.cs | 140 ++++++----------- ...MaskingUsingInitImageAlphaRequestBody.g.cs | 138 ++++++----------- ...ters.MaskingUsingMaskImageRequestBody.g.cs | 139 ++++++----------- ...JsonConverters.TextToImageRequestBody.g.cs | 138 ++++++----------- .../StabilityAI.JsonSerializerContext.g.cs | 1 + ...tabilityAI.JsonSerializerContextTypes.g.cs | 5 + 8 files changed, 296 insertions(+), 548 deletions(-) diff --git a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.AllOf2.g.cs b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.AllOf2.g.cs index 0113766..c45ae60 100644 --- a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.AllOf2.g.cs +++ b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.AllOf2.g.cs @@ -14,118 +14,36 @@ public class AllOfJsonConverter : global::System.Text.Json.Serialization 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(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) + + T1? value1 = default; + try { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); + value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - var __score0 = 0; + catch (global::System.Text.Json.JsonException) { - var __ti = typeInfoResolver.GetTypeInfo(typeof(T1), 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)) __score0++; - } - } } - var __score1 = 0; + catch (global::System.InvalidOperationException) { - var __ti = typeInfoResolver.GetTypeInfo(typeof(T2), 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)) __score1++; - } - } } - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - T1? value1 = default; T2? value2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - value1 = 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(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); + value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (value1 == null && value2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (value1 == null && value2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::StabilityAI.AllOf( value1, @@ -144,18 +62,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(global::System.StringComparer.Ordinal); if (value.IsValue1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Value1!, 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.IsValue2) + if (value.IsValue2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Value2!, 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(); } } } \ No newline at end of file diff --git a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.ImageToImageUsingImageStrengthRequestBody.g.cs b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.ImageToImageUsingImageStrengthRequestBody.g.cs index ff5790f..da92585 100644 --- a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.ImageToImageUsingImageStrengthRequestBody.g.cs +++ b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.ImageToImageUsingImageStrengthRequestBody.g.cs @@ -17,103 +17,34 @@ public class ImageToImageUsingImageStrengthRequestBodyJsonConverter : global::Sy using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1? imageToImageUsingImageStrengthRequestBodyVariant1 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1).Name}"); + imageToImageUsingImageStrengthRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("image_strength")) __score0++; - if (__jsonProps.Contains("init_image")) __score0++; - if (__jsonProps.Contains("init_image_mode")) __score0++; - if (__jsonProps.Contains("text_prompts")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("cfg_scale")) __score1++; - if (__jsonProps.Contains("clip_guidance_preset")) __score1++; - if (__jsonProps.Contains("sampler")) __score1++; - if (__jsonProps.Contains("samples")) __score1++; - if (__jsonProps.Contains("seed")) __score1++; - if (__jsonProps.Contains("steps")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1? imageToImageUsingImageStrengthRequestBodyVariant1 = default; global::StabilityAI.GenerationRequestOptionalParams? generationOptionalParams = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1).Name}"); - imageToImageUsingImageStrengthRequestBodyVariant1 = 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::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); + generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (imageToImageUsingImageStrengthRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1).Name}"); - imageToImageUsingImageStrengthRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (imageToImageUsingImageStrengthRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::StabilityAI.ImageToImageUsingImageStrengthRequestBody( imageToImageUsingImageStrengthRequestBodyVariant1, @@ -132,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(global::System.StringComparer.Ordinal); if (value.IsImageToImageUsingImageStrengthRequestBodyVariant1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.ImageToImageUsingImageStrengthRequestBodyVariant1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ImageToImageUsingImageStrengthRequestBodyVariant1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ImageToImageUsingImageStrengthRequestBodyVariant1!, 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.IsGenerationOptionalParams) + if (value.IsGenerationOptionalParams) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.GenerationOptionalParams!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.GenerationOptionalParams!, 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(); } } } \ No newline at end of file diff --git a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.ImageToImageUsingStepScheduleRequestBody.g.cs b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.ImageToImageUsingStepScheduleRequestBody.g.cs index c535f37..312e8b4 100644 --- a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.ImageToImageUsingStepScheduleRequestBody.g.cs +++ b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.ImageToImageUsingStepScheduleRequestBody.g.cs @@ -17,104 +17,34 @@ public class ImageToImageUsingStepScheduleRequestBodyJsonConverter : global::Sys using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1? imageToImageUsingStepScheduleRequestBodyVariant1 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1).Name}"); + imageToImageUsingStepScheduleRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("init_image")) __score0++; - if (__jsonProps.Contains("init_image_mode")) __score0++; - if (__jsonProps.Contains("step_schedule_end")) __score0++; - if (__jsonProps.Contains("step_schedule_start")) __score0++; - if (__jsonProps.Contains("text_prompts")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("cfg_scale")) __score1++; - if (__jsonProps.Contains("clip_guidance_preset")) __score1++; - if (__jsonProps.Contains("sampler")) __score1++; - if (__jsonProps.Contains("samples")) __score1++; - if (__jsonProps.Contains("seed")) __score1++; - if (__jsonProps.Contains("steps")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1? imageToImageUsingStepScheduleRequestBodyVariant1 = default; global::StabilityAI.GenerationRequestOptionalParams? generationOptionalParams = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1).Name}"); - imageToImageUsingStepScheduleRequestBodyVariant1 = 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::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); + generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (imageToImageUsingStepScheduleRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1).Name}"); - imageToImageUsingStepScheduleRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (imageToImageUsingStepScheduleRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::StabilityAI.ImageToImageUsingStepScheduleRequestBody( imageToImageUsingStepScheduleRequestBodyVariant1, @@ -133,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(global::System.StringComparer.Ordinal); if (value.IsImageToImageUsingStepScheduleRequestBodyVariant1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.ImageToImageUsingStepScheduleRequestBodyVariant1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ImageToImageUsingStepScheduleRequestBodyVariant1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ImageToImageUsingStepScheduleRequestBodyVariant1!, 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.IsGenerationOptionalParams) + if (value.IsGenerationOptionalParams) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.GenerationOptionalParams!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.GenerationOptionalParams!, 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(); } } } \ No newline at end of file diff --git a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.MaskingUsingInitImageAlphaRequestBody.g.cs b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.MaskingUsingInitImageAlphaRequestBody.g.cs index 236e6f1..e61c853 100644 --- a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.MaskingUsingInitImageAlphaRequestBody.g.cs +++ b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.MaskingUsingInitImageAlphaRequestBody.g.cs @@ -17,102 +17,34 @@ public class MaskingUsingInitImageAlphaRequestBodyJsonConverter : global::System using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1? maskingUsingInitImageAlphaRequestBodyVariant1 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1).Name}"); + maskingUsingInitImageAlphaRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("init_image")) __score0++; - if (__jsonProps.Contains("mask_source")) __score0++; - if (__jsonProps.Contains("text_prompts")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("cfg_scale")) __score1++; - if (__jsonProps.Contains("clip_guidance_preset")) __score1++; - if (__jsonProps.Contains("sampler")) __score1++; - if (__jsonProps.Contains("samples")) __score1++; - if (__jsonProps.Contains("seed")) __score1++; - if (__jsonProps.Contains("steps")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1? maskingUsingInitImageAlphaRequestBodyVariant1 = default; global::StabilityAI.GenerationRequestOptionalParams? generationOptionalParams = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1).Name}"); - maskingUsingInitImageAlphaRequestBodyVariant1 = 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::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); + generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (maskingUsingInitImageAlphaRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1).Name}"); - maskingUsingInitImageAlphaRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (maskingUsingInitImageAlphaRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::StabilityAI.MaskingUsingInitImageAlphaRequestBody( maskingUsingInitImageAlphaRequestBodyVariant1, @@ -131,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(global::System.StringComparer.Ordinal); if (value.IsMaskingUsingInitImageAlphaRequestBodyVariant1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.MaskingUsingInitImageAlphaRequestBodyVariant1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.MaskingUsingInitImageAlphaRequestBodyVariant1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.MaskingUsingInitImageAlphaRequestBodyVariant1!, 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.IsGenerationOptionalParams) + if (value.IsGenerationOptionalParams) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.GenerationOptionalParams!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.GenerationOptionalParams!, 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(); } } } \ No newline at end of file diff --git a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.MaskingUsingMaskImageRequestBody.g.cs b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.MaskingUsingMaskImageRequestBody.g.cs index 6a66c26..4d276f8 100644 --- a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.MaskingUsingMaskImageRequestBody.g.cs +++ b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.MaskingUsingMaskImageRequestBody.g.cs @@ -17,103 +17,34 @@ public class MaskingUsingMaskImageRequestBodyJsonConverter : global::System.Text using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1? maskingUsingMaskImageRequestBodyVariant1 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1).Name}"); + maskingUsingMaskImageRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("init_image")) __score0++; - if (__jsonProps.Contains("mask_image")) __score0++; - if (__jsonProps.Contains("mask_source")) __score0++; - if (__jsonProps.Contains("text_prompts")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("cfg_scale")) __score1++; - if (__jsonProps.Contains("clip_guidance_preset")) __score1++; - if (__jsonProps.Contains("sampler")) __score1++; - if (__jsonProps.Contains("samples")) __score1++; - if (__jsonProps.Contains("seed")) __score1++; - if (__jsonProps.Contains("steps")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1? maskingUsingMaskImageRequestBodyVariant1 = default; global::StabilityAI.GenerationRequestOptionalParams? generationOptionalParams = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1).Name}"); - maskingUsingMaskImageRequestBodyVariant1 = 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::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); + generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (maskingUsingMaskImageRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1).Name}"); - maskingUsingMaskImageRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (maskingUsingMaskImageRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::StabilityAI.MaskingUsingMaskImageRequestBody( maskingUsingMaskImageRequestBodyVariant1, @@ -132,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(global::System.StringComparer.Ordinal); if (value.IsMaskingUsingMaskImageRequestBodyVariant1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.MaskingUsingMaskImageRequestBodyVariant1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.MaskingUsingMaskImageRequestBodyVariant1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.MaskingUsingMaskImageRequestBodyVariant1!, 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.IsGenerationOptionalParams) + if (value.IsGenerationOptionalParams) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.GenerationOptionalParams!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.GenerationOptionalParams!, 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(); } } } \ No newline at end of file diff --git a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.TextToImageRequestBody.g.cs b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.TextToImageRequestBody.g.cs index 092b436..120e416 100644 --- a/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.TextToImageRequestBody.g.cs +++ b/src/libs/StabilityAI/Generated/StabilityAI.JsonConverters.TextToImageRequestBody.g.cs @@ -17,102 +17,34 @@ public class TextToImageRequestBodyJsonConverter : 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(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::StabilityAI.TextToImageRequestBodyVariant1? textToImageRequestBodyVariant1 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.TextToImageRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.TextToImageRequestBodyVariant1).Name}"); + textToImageRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("height")) __score0++; - if (__jsonProps.Contains("text_prompts")) __score0++; - if (__jsonProps.Contains("width")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("cfg_scale")) __score1++; - if (__jsonProps.Contains("clip_guidance_preset")) __score1++; - if (__jsonProps.Contains("sampler")) __score1++; - if (__jsonProps.Contains("samples")) __score1++; - if (__jsonProps.Contains("seed")) __score1++; - if (__jsonProps.Contains("steps")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::StabilityAI.TextToImageRequestBodyVariant1? textToImageRequestBodyVariant1 = default; global::StabilityAI.GenerationRequestOptionalParams? generationOptionalParams = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.TextToImageRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.TextToImageRequestBodyVariant1).Name}"); - textToImageRequestBodyVariant1 = 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::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); + generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (textToImageRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.TextToImageRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.TextToImageRequestBodyVariant1).Name}"); - textToImageRequestBodyVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (textToImageRequestBodyVariant1 == null && generationOptionalParams == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - generationOptionalParams = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::StabilityAI.TextToImageRequestBody( textToImageRequestBodyVariant1, @@ -131,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(global::System.StringComparer.Ordinal); if (value.IsTextToImageRequestBodyVariant1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.TextToImageRequestBodyVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.TextToImageRequestBodyVariant1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.TextToImageRequestBodyVariant1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.TextToImageRequestBodyVariant1!, 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.IsGenerationOptionalParams) + if (value.IsGenerationOptionalParams) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::StabilityAI.GenerationRequestOptionalParams), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::StabilityAI.GenerationRequestOptionalParams).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.GenerationOptionalParams!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.GenerationOptionalParams!, 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(); } } } \ No newline at end of file diff --git a/src/libs/StabilityAI/Generated/StabilityAI.JsonSerializerContext.g.cs b/src/libs/StabilityAI/Generated/StabilityAI.JsonSerializerContext.g.cs index 4a2e065..493048a 100644 --- a/src/libs/StabilityAI/Generated/StabilityAI.JsonSerializerContext.g.cs +++ b/src/libs/StabilityAI/Generated/StabilityAI.JsonSerializerContext.g.cs @@ -694,6 +694,7 @@ namespace StabilityAI typeof(global::StabilityAI.JsonConverters.UnixTimestampJsonConverter), })] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::StabilityAI.JsonSerializerContextTypes))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List), TypeInfoPropertyName = "SystemCollectionsGeneric_ObjectList")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::StabilityAI.Engine))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(string))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::StabilityAI.EngineType), TypeInfoPropertyName = "EngineType2")] diff --git a/src/libs/StabilityAI/Generated/StabilityAI.JsonSerializerContextTypes.g.cs b/src/libs/StabilityAI/Generated/StabilityAI.JsonSerializerContextTypes.g.cs index e60028e..40ca8b2 100644 --- a/src/libs/StabilityAI/Generated/StabilityAI.JsonSerializerContextTypes.g.cs +++ b/src/libs/StabilityAI/Generated/StabilityAI.JsonSerializerContextTypes.g.cs @@ -20,6 +20,11 @@ public sealed partial class JsonSerializerContextTypes /// public global::System.Collections.Generic.Dictionary? StringObjectDictionary { get; set; } + /// + /// Runtime object lists used by dynamic JSON payloads such as tool arguments. + /// + public global::System.Collections.Generic.List? ObjectList { get; set; } + /// /// ///