Skip to content

Commit 45bdb39

Browse files
Copilothalter73
andcommitted
Add StringSyntax attributes to URI string properties
Added [StringSyntax(StringSyntaxAttribute.Uri)] to all URI string properties in ProtectedResourceMetadata: - Resource - JwksUri - ResourceDocumentation - ResourcePolicyUri - ResourceTosUri This provides better IDE support and validation for URI strings, consistent with other protocol types like ReadResourceRequestParams. Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
1 parent 77709e5 commit 45bdb39

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/ModelContextProtocol.Core/Authentication/ProtectedResourceMetadata.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics.CodeAnalysis;
12
using System.Text.Json.Serialization;
23

34
namespace ModelContextProtocol.Authentication;
@@ -20,6 +21,7 @@ public sealed class ProtectedResourceMetadata
2021
/// <b>Resource</b> must be explicitly set. Automatic inference only works with the default endpoint pattern.
2122
/// </remarks>
2223
[JsonPropertyName("resource")]
24+
[StringSyntax(StringSyntaxAttribute.Uri)]
2325
public string? Resource { get; set; }
2426

2527
/// <summary>
@@ -69,6 +71,7 @@ public sealed class ProtectedResourceMetadata
6971
/// that the resource server uses to sign resource responses. This URL MUST use the HTTPS scheme.
7072
/// </remarks>
7173
[JsonPropertyName("jwks_uri")]
74+
[StringSyntax(StringSyntaxAttribute.Uri)]
7275
public string? JwksUri { get; set; }
7376

7477
/// <summary>
@@ -105,6 +108,7 @@ public sealed class ProtectedResourceMetadata
105108
/// OPTIONAL.
106109
/// </remarks>
107110
[JsonPropertyName("resource_documentation")]
111+
[StringSyntax(StringSyntaxAttribute.Uri)]
108112
public string? ResourceDocumentation { get; set; }
109113

110114
/// <summary>
@@ -117,6 +121,7 @@ public sealed class ProtectedResourceMetadata
117121
/// OPTIONAL.
118122
/// </remarks>
119123
[JsonPropertyName("resource_policy_uri")]
124+
[StringSyntax(StringSyntaxAttribute.Uri)]
120125
public string? ResourcePolicyUri { get; set; }
121126

122127
/// <summary>
@@ -126,6 +131,7 @@ public sealed class ProtectedResourceMetadata
126131
/// OPTIONAL. The value of this field MAY be internationalized.
127132
/// </remarks>
128133
[JsonPropertyName("resource_tos_uri")]
134+
[StringSyntax(StringSyntaxAttribute.Uri)]
129135
public string? ResourceTosUri { get; set; }
130136

131137
/// <summary>

0 commit comments

Comments
 (0)