Fix enum serialization (#61)
* Fix enum serialization * Add tests for enum serialization * Add missing enum serialization configuration. * Ensure enums serialize as expected using defaults --------- Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
This commit is contained in:
parent
1a5732b158
commit
96ba2fa076
3 changed files with 58 additions and 28 deletions
|
|
@ -1,23 +1,29 @@
|
|||
namespace ModelContextProtocol.Protocol.Types;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ModelContextProtocol.Protocol.Types;
|
||||
|
||||
/// <summary>
|
||||
/// A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(JsonStringEnumConverter<ContextInclusion>))]
|
||||
public enum ContextInclusion
|
||||
{
|
||||
/// <summary>
|
||||
/// No context should be included.
|
||||
/// </summary>
|
||||
[JsonStringEnumMemberName("none")]
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Include context from the server that sent the request.
|
||||
/// </summary>
|
||||
[JsonStringEnumMemberName("thisServer")]
|
||||
ThisServer,
|
||||
|
||||
/// <summary>
|
||||
/// Include context from all servers that the client is connected to.
|
||||
/// </summary>
|
||||
[JsonStringEnumMemberName("allServers")]
|
||||
AllServers
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,37 +7,38 @@ namespace ModelContextProtocol.Protocol.Types;
|
|||
/// These map to syslog message severities, as specified in RFC-5424:
|
||||
/// https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(JsonStringEnumConverter<LoggingLevel>))]
|
||||
public enum LoggingLevel
|
||||
{
|
||||
/// <summary>Detailed debug information, typically only valuable to developers.</summary>
|
||||
[JsonPropertyName("debug")]
|
||||
[JsonStringEnumMemberName("debug")]
|
||||
Debug,
|
||||
|
||||
/// <summary>Normal operational messages that require no action.</summary>
|
||||
[JsonPropertyName("info")]
|
||||
[JsonStringEnumMemberName("info")]
|
||||
Info,
|
||||
|
||||
/// <summary>Normal but significant events that might deserve attention.</summary>
|
||||
[JsonPropertyName("notice")]
|
||||
[JsonStringEnumMemberName("notice")]
|
||||
Notice,
|
||||
|
||||
/// <summary>Warning conditions that don't represent an error but indicate potential issues.</summary>
|
||||
[JsonPropertyName("warning")]
|
||||
[JsonStringEnumMemberName("warning")]
|
||||
Warning,
|
||||
|
||||
/// <summary>Error conditions that should be addressed but don't require immediate action.</summary>
|
||||
[JsonPropertyName("error")]
|
||||
[JsonStringEnumMemberName("error")]
|
||||
Error,
|
||||
|
||||
/// <summary>Critical conditions that require immediate attention.</summary>
|
||||
[JsonPropertyName("critical")]
|
||||
[JsonStringEnumMemberName("critical")]
|
||||
Critical,
|
||||
|
||||
/// <summary>Action must be taken immediately to address the condition.</summary>
|
||||
[JsonPropertyName("alert")]
|
||||
[JsonStringEnumMemberName("alert")]
|
||||
Alert,
|
||||
|
||||
/// <summary>System is unusable and requires immediate attention.</summary>
|
||||
[JsonPropertyName("emergency")]
|
||||
[JsonStringEnumMemberName("emergency")]
|
||||
Emergency
|
||||
}
|
||||
|
|
@ -6,17 +6,18 @@ namespace ModelContextProtocol.Protocol.Types;
|
|||
/// Represents the type of role in the conversation.
|
||||
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(JsonStringEnumConverter<Role>))]
|
||||
public enum Role
|
||||
{
|
||||
/// <summary>
|
||||
/// Corresponds to the user in the conversation.
|
||||
/// </summary>
|
||||
[JsonPropertyName("user")]
|
||||
[JsonStringEnumMemberName("user")]
|
||||
User,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to the AI in the conversation.
|
||||
/// </summary>
|
||||
[JsonPropertyName("assistant")]
|
||||
[JsonStringEnumMemberName("assistant")]
|
||||
Assistant
|
||||
}
|
||||
Loading…
Reference in a new issue