Skip to content

Commit 6383dde

Browse files
committed
Add [Description] to DataContent.Uri
So that if a DataContent has schema generated for it, it's obvious in the schema that the "uri" is specifically a data URI.
1 parent acf1d45 commit 6383dde

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#if NET
66
using System.Buffers;
77
using System.Buffers.Text;
8+
using System.ComponentModel;
89
#endif
910
using System.Diagnostics;
1011
using System.Diagnostics.CodeAnalysis;
@@ -142,6 +143,9 @@ public DataContent(ReadOnlyMemory<byte> data, string mediaType)
142143
/// or from a <see cref="System.Uri"/>.
143144
/// </remarks>
144145
[StringSyntax(StringSyntaxAttribute.Uri)]
146+
#if NET
147+
[Description("A data URI representing the content.")]
148+
#endif
145149
public string Uri
146150
{
147151
get

test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Contents/DataContentTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ public void Serialize_Deserialize_Roundtrips(string serialized, string expectedT
179179
Assert.Equal(expectedToString, reSerialization);
180180
}
181181

182+
[Fact]
183+
public void GenerateSchema_ContainsDataUriDescription()
184+
{
185+
var schema = AIJsonUtilities.CreateJsonSchema(typeof(DataContent), serializerOptions: AIJsonUtilities.DefaultOptions);
186+
Assert.Contains("data URI", schema.ToString());
187+
}
188+
182189
[Theory]
183190
[InlineData("application/json")]
184191
[InlineData("application/octet-stream")]

0 commit comments

Comments
 (0)