Skip to content

Commit

Permalink
fix: Fixed issue with allOf'2 with nullable: true as one of item.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 12, 2024
1 parent 62f24c2 commit a1f4e46
Show file tree
Hide file tree
Showing 35 changed files with 934 additions and 1,616 deletions.
28 changes: 28 additions & 0 deletions src/libs/AutoSDK/Helpers/OpenApi31Support.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,34 @@ private static void ConvertYamlNode(Dictionary<object, object?> node)
node[new string("exclusiveMaximum".ToCharArray())] = true;
}

if (keyString == "allOf" &&
entry.Value is List<object?> { Count: 2 } allOfItems &&
allOfItems.Any(v =>
v is Dictionary<object, object?> objects &&
objects.ContainsKey("nullable") &&
objects["nullable"] is true))
{
var first = allOfItems[0] as Dictionary<object, object?>;
var second = allOfItems[1] as Dictionary<object, object?>;

if (first?.ContainsKey("nullable") != true)
{
foreach (var key in first ?? new Dictionary<object, object?>())
{
node[key.Key] = key.Value;
}
}
else
{
foreach (var key in second ?? new Dictionary<object, object?>())
{
node[key.Key] = key.Value;
}
}

node.Remove(keyString);
}

// Remove "prefixItems"
if (keyString == "prefixItems" && entry.Value is List<object?> { Count: > 0 } prefixItemsList)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed partial class ChatCompletionChoice
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("finish_reason", Required = global::Newtonsoft.Json.Required.Always)]
public global::G.FinishReason2 FinishReason { get; set; } = default!;
public global::G.FinishReason FinishReason { get; set; } = default!;

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//HintName: G.Models.ChatCompletionChoicesDataItem.g.cs

#pragma warning disable CS0618 // Type or member is obsolete

#nullable enable

namespace G
Expand All @@ -15,7 +13,7 @@ public sealed partial class ChatCompletionChoicesDataItem
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("finish_reason")]
public global::G.FinishReason2? FinishReason { get; set; }
public global::G.FinishReason? FinishReason { get; set; }

/// <summary>
///
Expand All @@ -27,7 +25,7 @@ public sealed partial class ChatCompletionChoicesDataItem
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("logprobs")]
public global::G.AllOf<object, global::G.LogprobsPart>? Logprobs { get; set; }
public global::G.LogprobsPart? Logprobs { get; set; }

/// <summary>
///
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//HintName: G.Models.ChatCompletionChunk.g.cs

#pragma warning disable CS0618 // Type or member is obsolete

#nullable enable

namespace G
Expand Down Expand Up @@ -51,7 +49,7 @@ public sealed partial class ChatCompletionChunk
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("usage")]
public global::G.AllOf<global::G.UsageData, object>? Usage { get; set; }
public global::G.UsageData? Usage { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed partial class ChatCompletionChunkChoice
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("finish_reason", Required = global::Newtonsoft.Json.Required.Always)]
public global::G.FinishReason2 FinishReason { get; set; } = default!;
public global::G.FinishReason FinishReason { get; set; } = default!;

/// <summary>
///
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class CompletionChoicesDataItem
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("finish_reason")]
public global::G.FinishReason2? FinishReason { get; set; }
public global::G.FinishReason? FinishReason { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//HintName: G.Models.CompletionChunk.g.cs

#pragma warning disable CS0618 // Type or member is obsolete

#nullable enable

namespace G
Expand All @@ -21,7 +19,7 @@ public sealed partial class CompletionChunk
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("finish_reason", Required = global::Newtonsoft.Json.Required.Always)]
public global::G.AllOf<global::G.FinishReason2?, object> FinishReason { get; set; } = default!;
public global::G.FinishReason FinishReason { get; set; } = default!;

/// <summary>
///
Expand All @@ -45,7 +43,7 @@ public sealed partial class CompletionChunk
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("usage", Required = global::Newtonsoft.Json.Required.Always)]
public global::G.AllOf<global::G.UsageData, object> Usage { get; set; } = default!;
public global::G.UsageData? Usage { get; set; } = default!;

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Loading

0 comments on commit a1f4e46

Please sign in to comment.