Skip to content

Commit 95f6e01

Browse files
committed
Update generated code
1 parent 6fcfedb commit 95f6e01

18 files changed

+106
-41
lines changed

src/Generated/Models/Chat/ChatMessage.Serialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
3636
writer.WritePropertyName("content"u8);
3737
SerializeContentValue(writer, options);
3838
}
39+
40+
Patch.WriteTo(writer);
3941
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
4042
}
4143

src/Generated/Models/Chat/ChatMessageContentPart.Serialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
2222
throw new FormatException($"The model {nameof(ChatMessageContentPart)} does not support writing '{format}' format.");
2323
}
2424
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
25+
26+
Patch.WriteTo(writer);
2527
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
2628
}
2729

src/Generated/Models/Chat/ChatOutputPrediction.Serialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
4444
writer.WritePropertyName("type"u8);
4545
writer.WriteStringValue(Kind.ToString());
4646
}
47+
48+
Patch.WriteTo(writer);
4749
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
4850
}
4951

src/Generated/Models/Chat/ChatResponseFormat.Serialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
3131
writer.WritePropertyName("type"u8);
3232
writer.WriteStringValue(Kind.ToString());
3333
}
34+
35+
Patch.WriteTo(writer);
3436
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
3537
}
3638

src/Generated/Models/Responses/CodeInterpreterCallOutput.Serialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
4444
writer.WritePropertyName("type"u8);
4545
writer.WriteStringValue(Kind.ToString());
4646
}
47+
48+
Patch.WriteTo(writer);
4749
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
4850
}
4951

src/Generated/Models/Responses/CodeInterpreterToolContainerConfiguration.Serialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
4444
writer.WritePropertyName("type"u8);
4545
writer.WriteStringValue(Kind.ToString());
4646
}
47+
48+
Patch.WriteTo(writer);
4749
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
4850
}
4951

src/Generated/Models/Responses/ComputerCallAction.Serialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
4444
writer.WritePropertyName("type"u8);
4545
writer.WriteStringValue(Kind.ToSerialString());
4646
}
47+
48+
Patch.WriteTo(writer);
4749
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
4850
}
4951

src/Generated/Models/Responses/ComputerCallOutput.Serialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
4444
writer.WritePropertyName("type"u8);
4545
writer.WriteStringValue(Kind.ToString());
4646
}
47+
48+
Patch.WriteTo(writer);
4749
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
4850
}
4951

src/Generated/Models/Responses/InternalMCPToolRequireApproval1.Serialization.cs

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using System;
66
using System.ClientModel.Primitives;
7-
using System.Collections.Generic;
7+
using System.Text;
88
using System.Text.Json;
99
using OpenAI;
1010

@@ -14,6 +14,14 @@ internal partial class InternalMCPToolRequireApproval1 : IJsonModel<InternalMCPT
1414
{
1515
void IJsonModel<InternalMCPToolRequireApproval1>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
1616
{
17+
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
18+
if (Patch.Contains("$"u8))
19+
{
20+
writer.WriteRawValue(Patch.GetJson("$"u8));
21+
return;
22+
}
23+
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
24+
1725
writer.WriteStartObject();
1826
JsonModelWriteCore(writer, options);
1927
writer.WriteEndObject();
@@ -26,36 +34,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
2634
{
2735
throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support writing '{format}' format.");
2836
}
29-
if (Optional.IsDefined(Always) && _additionalBinaryDataProperties?.ContainsKey("always") != true)
37+
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
38+
if (Optional.IsDefined(Always) && !Patch.Contains("$.always"u8))
3039
{
3140
writer.WritePropertyName("always"u8);
3241
writer.WriteObjectValue(Always, options);
3342
}
34-
if (Optional.IsDefined(Never) && _additionalBinaryDataProperties?.ContainsKey("never") != true)
43+
if (Optional.IsDefined(Never) && !Patch.Contains("$.never"u8))
3544
{
3645
writer.WritePropertyName("never"u8);
3746
writer.WriteObjectValue(Never, options);
3847
}
39-
// Plugin customization: remove options.Format != "W" check
40-
if (_additionalBinaryDataProperties != null)
41-
{
42-
foreach (var item in _additionalBinaryDataProperties)
43-
{
44-
if (ModelSerializationExtensions.IsSentinelValue(item.Value))
45-
{
46-
continue;
47-
}
48-
writer.WritePropertyName(item.Key);
49-
#if NET6_0_OR_GREATER
50-
writer.WriteRawValue(item.Value);
51-
#else
52-
using (JsonDocument document = JsonDocument.Parse(item.Value))
53-
{
54-
JsonSerializer.Serialize(writer, document.RootElement);
55-
}
56-
#endif
57-
}
58-
}
48+
49+
Patch.WriteTo(writer);
50+
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
5951
}
6052

6153
InternalMCPToolRequireApproval1 IJsonModel<InternalMCPToolRequireApproval1>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);
@@ -68,18 +60,20 @@ protected virtual InternalMCPToolRequireApproval1 JsonModelCreateCore(ref Utf8Js
6860
throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support reading '{format}' format.");
6961
}
7062
using JsonDocument document = JsonDocument.ParseValue(ref reader);
71-
return DeserializeInternalMCPToolRequireApproval1(document.RootElement, options);
63+
return DeserializeInternalMCPToolRequireApproval1(document.RootElement, null, options);
7264
}
7365

74-
internal static InternalMCPToolRequireApproval1 DeserializeInternalMCPToolRequireApproval1(JsonElement element, ModelReaderWriterOptions options)
66+
internal static InternalMCPToolRequireApproval1 DeserializeInternalMCPToolRequireApproval1(JsonElement element, BinaryData data, ModelReaderWriterOptions options)
7567
{
7668
if (element.ValueKind == JsonValueKind.Null)
7769
{
7870
return null;
7971
}
8072
McpToolFilter always = default;
8173
McpToolFilter never = default;
82-
IDictionary<string, BinaryData> additionalBinaryDataProperties = new ChangeTrackingDictionary<string, BinaryData>();
74+
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
75+
JsonPatch patch = new JsonPatch(data is null ? ReadOnlyMemory<byte>.Empty : data.ToMemory());
76+
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
8377
foreach (var prop in element.EnumerateObject())
8478
{
8579
if (prop.NameEquals("always"u8))
@@ -100,10 +94,9 @@ internal static InternalMCPToolRequireApproval1 DeserializeInternalMCPToolRequir
10094
never = McpToolFilter.DeserializeMcpToolFilter(prop.Value, prop.Value.GetUtf8Bytes(), options);
10195
continue;
10296
}
103-
// Plugin customization: remove options.Format != "W" check
104-
additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
97+
patch.Set([.. "$."u8, .. Encoding.UTF8.GetBytes(prop.Name)], prop.Value.GetUtf8Bytes());
10598
}
106-
return new InternalMCPToolRequireApproval1(always, never, additionalBinaryDataProperties);
99+
return new InternalMCPToolRequireApproval1(always, never, patch);
107100
}
108101

109102
BinaryData IPersistableModel<InternalMCPToolRequireApproval1>.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
@@ -130,13 +123,50 @@ protected virtual InternalMCPToolRequireApproval1 PersistableModelCreateCore(Bin
130123
case "J":
131124
using (JsonDocument document = JsonDocument.Parse(data))
132125
{
133-
return DeserializeInternalMCPToolRequireApproval1(document.RootElement, options);
126+
return DeserializeInternalMCPToolRequireApproval1(document.RootElement, data, options);
134127
}
135128
default:
136129
throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support reading '{options.Format}' format.");
137130
}
138131
}
139132

140133
string IPersistableModel<InternalMCPToolRequireApproval1>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
134+
135+
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
136+
private bool PropagateGet(ReadOnlySpan<byte> jsonPath, out JsonPatch.EncodedValue value)
137+
{
138+
ReadOnlySpan<byte> local = jsonPath.SliceToStartOfPropertyName();
139+
value = default;
140+
141+
if (local.StartsWith("always"u8))
142+
{
143+
return Always.Patch.TryGetEncodedValue([.. "$"u8, .. local.Slice("always"u8.Length)], out value);
144+
}
145+
if (local.StartsWith("never"u8))
146+
{
147+
return Never.Patch.TryGetEncodedValue([.. "$"u8, .. local.Slice("never"u8.Length)], out value);
148+
}
149+
return false;
150+
}
151+
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
152+
153+
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
154+
private bool PropagateSet(ReadOnlySpan<byte> jsonPath, JsonPatch.EncodedValue value)
155+
{
156+
ReadOnlySpan<byte> local = jsonPath.SliceToStartOfPropertyName();
157+
158+
if (local.StartsWith("always"u8))
159+
{
160+
Always.Patch.Set([.. "$"u8, .. local.Slice("always"u8.Length)], value);
161+
return true;
162+
}
163+
if (local.StartsWith("never"u8))
164+
{
165+
Never.Patch.Set([.. "$"u8, .. local.Slice("never"u8.Length)], value);
166+
return true;
167+
}
168+
return false;
169+
}
170+
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
141171
}
142172
}

src/Generated/Models/Responses/InternalMCPToolRequireApproval1.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,37 @@
22

33
#nullable disable
44

5-
using System;
6-
using System.Collections.Generic;
5+
using System.ClientModel.Primitives;
6+
using System.ComponentModel;
7+
using System.Diagnostics.CodeAnalysis;
78

89
namespace OpenAI.Responses
910
{
1011
internal partial class InternalMCPToolRequireApproval1
1112
{
12-
private protected IDictionary<string, BinaryData> _additionalBinaryDataProperties;
13+
[Experimental("SCME0001")]
14+
private JsonPatch _patch;
1315

1416
public InternalMCPToolRequireApproval1()
1517
{
1618
}
1719

18-
internal InternalMCPToolRequireApproval1(McpToolFilter always, McpToolFilter never, IDictionary<string, BinaryData> additionalBinaryDataProperties)
20+
#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
21+
internal InternalMCPToolRequireApproval1(McpToolFilter always, McpToolFilter never, in JsonPatch patch)
1922
{
2023
Always = always;
2124
Never = never;
22-
_additionalBinaryDataProperties = additionalBinaryDataProperties;
25+
_patch = patch;
26+
_patch.SetPropagators(PropagateSet, PropagateGet);
2327
}
28+
#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
29+
30+
[EditorBrowsable(EditorBrowsableState.Never)]
31+
[Experimental("SCME0001")]
32+
public ref JsonPatch Patch => ref _patch;
2433

2534
public McpToolFilter Always { get; set; }
2635

2736
public McpToolFilter Never { get; set; }
28-
29-
internal IDictionary<string, BinaryData> SerializedAdditionalRawData
30-
{
31-
get => _additionalBinaryDataProperties;
32-
set => _additionalBinaryDataProperties = value;
33-
}
3437
}
3538
}

0 commit comments

Comments
 (0)