Refactor Resource/ResourceTemplate to subclass Annotated (#50)

The `Resource` and `ResourceTemplate` types should derive from a base `Annotated` type having the `Annotations` property as per the [spec](https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts#L821)

This small change makes the C# types match the schema more closely.

Also renamed Resources.cs to Resource.cs to reflect the type name.
This commit is contained in:
Jonathan Dick 2025-03-21 15:10:27 -04:00 • committed by GitHub
commit 0cbcad7447
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,7 +8,7 @@ namespace ModelContextProtocol.Protocol.Types;
/// Represents a known resource template that the server is capable of reading.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
/// </summary>
public record ResourceTemplate
public record ResourceTemplate : Annotated
{
/// <summary>
/// The URI template (according to RFC 6570) that can be used to construct resource URIs.
@ -33,10 +33,4 @@ public record ResourceTemplate
/// </summary>
[JsonPropertyName("mimeType")]
public string? MimeType { get; init; }
/// <summary>
/// Optional annotations for the resource template.
/// </summary>
[JsonPropertyName("annotations")]
public Annotations? Annotations { get; init; }
}