Skip to content

Commit 56fb5f8

Browse files
committed
fix: Fixed issue with invalid default value for big AnyOfs.
1 parent 9b5ddee commit 56fb5f8

File tree

4 files changed

+9
-30
lines changed

4 files changed

+9
-30
lines changed

src/libs/AutoSDK/Extensions/OpenApiExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,14 @@ context.Schema.Default is OpenApiArray ||
466466
}
467467
if (context.Schema.Default is OpenApiString @string && !string.IsNullOrWhiteSpace(@string.Value))
468468
{
469+
if (context.Schema.Type != "string" &&
470+
context.Schema.AnyOf.All(x => x.Type != "string") &&
471+
context.Schema.AllOf.All(x => x.Type != "string") &&
472+
context.Schema.OneOf.All(x => x.Type != "string"))
473+
{
474+
return null;
475+
}
476+
469477
return $"\"{@string.Value}\"";
470478
}
471479

src/tests/AutoSDK.SnapshotTests/Snapshots/openai/NewtonsoftJson/_#G.Models.Eval.g.verified.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public sealed partial class Eval
4848
/// A list of testing criteria.<br/>
4949
/// Default Value: eval
5050
/// </summary>
51-
/// <default>"eval"</default>
5251
[global::Newtonsoft.Json.JsonProperty("testing_criteria", Required = global::Newtonsoft.Json.Required.Always)]
5352
public global::System.Collections.Generic.IList<global::G.OneOf<global::G.EvalLabelModelGrader, global::G.EvalStringCheckGrader, global::G.EvalTextSimilarityGrader, global::G.EvalPythonGrader, global::G.EvalScoreModelGrader>> TestingCriteria { get; set; } = default!;
5453

src/tests/AutoSDK.SnapshotTests/Snapshots/openai/SystemTextJson/Tests.SdkGenerator_Diagnostics.received.txt

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/tests/AutoSDK.SnapshotTests/Snapshots/openai/SystemTextJson/_#G.Models.Eval.g.verified.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ public sealed partial class Eval
5353
/// A list of testing criteria.<br/>
5454
/// Default Value: eval
5555
/// </summary>
56-
/// <default>"eval"</default>
5756
[global::System.Text.Json.Serialization.JsonPropertyName("testing_criteria")]
5857
[global::System.Text.Json.Serialization.JsonRequired]
59-
public required global::System.Collections.Generic.IList<global::G.OneOf<global::G.EvalLabelModelGrader, global::G.EvalStringCheckGrader, global::G.EvalTextSimilarityGrader, global::G.EvalPythonGrader, global::G.EvalScoreModelGrader>> TestingCriteria { get; set; } = "eval";
58+
public required global::System.Collections.Generic.IList<global::G.OneOf<global::G.EvalLabelModelGrader, global::G.EvalStringCheckGrader, global::G.EvalTextSimilarityGrader, global::G.EvalPythonGrader, global::G.EvalScoreModelGrader>> TestingCriteria { get; set; }
6059

6160
/// <summary>
6261
/// The Unix timestamp (in seconds) for when the eval was created.

0 commit comments

Comments
 (0)