Skip to content

Commit 8daa493

Browse files
committed
fix: Fixed issue with some default values for LangSmith.
1 parent bae01f3 commit 8daa493

File tree

32 files changed

+395
-33
lines changed

32 files changed

+395
-33
lines changed

src/libs/OpenApiGenerator.Core/Extensions/OpenApiExtensions.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,25 @@ public static string PreparePath(
9292
var enumChildContext = context.Children
9393
.Where(x => x.Hint is Hint.AnyOf)
9494
.First(x => x.Schema.Enum.Any());
95+
96+
var value = context.Schema.Default.ToEnumValue(context.Settings).Name;
97+
if (string.IsNullOrWhiteSpace(value))
98+
{
99+
if (context.Children
100+
.Where(x => x.Hint is Hint.AnyOf)
101+
.Any(x => x.Schema.Type == "string"))
102+
{
103+
value = context.Schema.Default.GetString();
104+
if (!string.IsNullOrWhiteSpace(value))
105+
{
106+
return $"\"{value}\"";
107+
}
108+
}
109+
110+
return null;
111+
}
95112

96-
return enumChildContext.TypeData?.CSharpTypeWithoutNullability + "." + context.Schema.Default.ToEnumValue(context.Settings).Name;
113+
return enumChildContext.TypeData?.CSharpTypeWithoutNullability + "." + value;
97114
}
98115
if (context.Schema.OneOf.Any(x => x.Enum.Any()) && context.Schema.Default != null)
99116
{

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.ChartsClient.CreateChart.g.verified.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ partial void ProcessCreateChartResponseContent(
109109
/// <param name="series"></param>
110110
/// <param name="sectionId"></param>
111111
/// <param name="metadata"></param>
112+
/// <param name="commonFilters"></param>
112113
/// <param name="cancellationToken">The token to cancel the operation with</param>
113114
/// <exception cref="global::System.InvalidOperationException"></exception>
114115
public async global::System.Threading.Tasks.Task<global::G.CustomChartResponse> CreateChartAsync(
@@ -119,6 +120,7 @@ partial void ProcessCreateChartResponseContent(
119120
global::System.AnyOf<int?, object>? index = default,
120121
global::System.AnyOf<string, object>? sectionId = default,
121122
global::System.AnyOf<global::G.CustomChartCreateMetadata, object>? metadata = default,
123+
global::System.AnyOf<global::G.CustomChartSeriesFilters, object>? commonFilters = default,
122124
global::System.Threading.CancellationToken cancellationToken = default)
123125
{
124126
var request = new global::G.CustomChartCreate
@@ -130,6 +132,7 @@ partial void ProcessCreateChartResponseContent(
130132
Series = series,
131133
SectionId = sectionId,
132134
Metadata = metadata,
135+
CommonFilters = commonFilters,
133136
};
134137

135138
return await CreateChartAsync(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.ChartsClient.UpdateChart.g.verified.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ partial void ProcessUpdateChartResponseContent(
114114
/// <param name="series"></param>
115115
/// <param name="sectionId"></param>
116116
/// <param name="metadata"></param>
117+
/// <param name="commonFilters"></param>
117118
/// <param name="cancellationToken">The token to cancel the operation with</param>
118119
/// <exception cref="global::System.InvalidOperationException"></exception>
119120
public async global::System.Threading.Tasks.Task<global::G.CustomChartResponse> UpdateChartAsync(
@@ -125,6 +126,7 @@ partial void ProcessUpdateChartResponseContent(
125126
global::System.AnyOf<global::System.Collections.Generic.IList<global::G.CustomChartSeriesUpdate>, global::G.Missing>? series = default,
126127
global::System.AnyOf<string, global::G.Missing>? sectionId = default,
127128
global::System.AnyOf<global::G.CustomChartUpdateMetadata, global::G.Missing, object>? metadata = default,
129+
global::System.AnyOf<global::G.CustomChartSeriesFilters, global::G.Missing, object>? commonFilters = default,
128130
global::System.Threading.CancellationToken cancellationToken = default)
129131
{
130132
var request = new global::G.CustomChartUpdate
@@ -136,6 +138,7 @@ partial void ProcessUpdateChartResponseContent(
136138
Series = series,
137139
SectionId = sectionId,
138140
Metadata = metadata,
141+
CommonFilters = commonFilters,
139142
};
140143

141144
return await UpdateChartAsync(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.Models.CustomChartCreate.g.verified.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public sealed partial class CustomChartCreate
5353
[global::Newtonsoft.Json.JsonProperty("metadata")]
5454
public global::System.AnyOf<global::G.CustomChartCreateMetadata, object>? Metadata { get; set; }
5555

56+
/// <summary>
57+
///
58+
/// </summary>
59+
[global::Newtonsoft.Json.JsonProperty("common_filters")]
60+
public global::System.AnyOf<global::G.CustomChartSeriesFilters, object>? CommonFilters { get; set; }
61+
5662
/// <summary>
5763
/// Additional properties that are not explicitly defined in the schema
5864
/// </summary>

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.Models.CustomChartCreatePreview.g.verified.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//HintName: G.Models.CustomChartCreatePreview.g.cs
22

3+
#pragma warning disable CS0618 // Type or member is obsolete
4+
35
#nullable enable
46

57
namespace G
@@ -15,6 +17,12 @@ public sealed partial class CustomChartCreatePreview
1517
[global::Newtonsoft.Json.JsonProperty("series", Required = global::Newtonsoft.Json.Required.Always)]
1618
public global::System.Collections.Generic.IList<global::G.CustomChartSeries> Series { get; set; } = default!;
1719

20+
/// <summary>
21+
///
22+
/// </summary>
23+
[global::Newtonsoft.Json.JsonProperty("common_filters")]
24+
public global::System.AnyOf<global::G.CustomChartSeriesFilters, object>? CommonFilters { get; set; }
25+
1826
/// <summary>
1927
/// Additional properties that are not explicitly defined in the schema
2028
/// </summary>

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.Models.CustomChartSeries.g.verified.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public sealed partial class CustomChartSeries
2020
/// <summary>
2121
///
2222
/// </summary>
23-
[global::Newtonsoft.Json.JsonProperty("filters", Required = global::Newtonsoft.Json.Required.Always)]
24-
public global::G.CustomChartSeriesFilters Filters { get; set; } = default!;
23+
[global::Newtonsoft.Json.JsonProperty("filters")]
24+
public global::System.AnyOf<global::G.CustomChartSeriesFilters, object>? Filters { get; set; }
2525

2626
/// <summary>
2727
/// Metrics you can chart.

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.Models.CustomChartSeriesCreate.g.verified.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public sealed partial class CustomChartSeriesCreate
2020
/// <summary>
2121
///
2222
/// </summary>
23-
[global::Newtonsoft.Json.JsonProperty("filters", Required = global::Newtonsoft.Json.Required.Always)]
24-
public global::G.CustomChartSeriesFilters Filters { get; set; } = default!;
23+
[global::Newtonsoft.Json.JsonProperty("filters")]
24+
public global::System.AnyOf<global::G.CustomChartSeriesFilters, object>? Filters { get; set; }
2525

2626
/// <summary>
2727
/// Metrics you can chart.

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.Models.CustomChartSeriesFilters.g.verified.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public sealed partial class CustomChartSeriesFilters
3232
/// <summary>
3333
///
3434
/// </summary>
35-
[global::Newtonsoft.Json.JsonProperty("session", Required = global::Newtonsoft.Json.Required.Always)]
36-
public global::System.Collections.Generic.IList<string> Session { get; set; } = default!;
35+
[global::Newtonsoft.Json.JsonProperty("session")]
36+
public global::System.AnyOf<global::System.Collections.Generic.IList<string>, object>? Session { get; set; }
3737

3838
/// <summary>
3939
/// Additional properties that are not explicitly defined in the schema

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.Models.CustomChartSeriesUpdate.g.verified.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public sealed partial class CustomChartSeriesUpdate
2020
/// <summary>
2121
///
2222
/// </summary>
23-
[global::Newtonsoft.Json.JsonProperty("filters", Required = global::Newtonsoft.Json.Required.Always)]
24-
public global::G.CustomChartSeriesFilters Filters { get; set; } = default!;
23+
[global::Newtonsoft.Json.JsonProperty("filters")]
24+
public global::System.AnyOf<global::G.CustomChartSeriesFilters, object>? Filters { get; set; }
2525

2626
/// <summary>
2727
/// Metrics you can chart.

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.Models.CustomChartUpdate.g.verified.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public sealed partial class CustomChartUpdate
5353
[global::Newtonsoft.Json.JsonProperty("metadata")]
5454
public global::System.AnyOf<global::G.CustomChartUpdateMetadata, global::G.Missing, object>? Metadata { get; set; }
5555

56+
/// <summary>
57+
///
58+
/// </summary>
59+
[global::Newtonsoft.Json.JsonProperty("common_filters")]
60+
public global::System.AnyOf<global::G.CustomChartSeriesFilters, global::G.Missing, object>? CommonFilters { get; set; }
61+
5662
/// <summary>
5763
/// Additional properties that are not explicitly defined in the schema
5864
/// </summary>

0 commit comments

Comments
 (0)