Skip to content

Commit

Permalink
Refactor JSON serialization for string-valued enums
Browse files Browse the repository at this point in the history
  • Loading branch information
patchoulish committed Nov 16, 2024
1 parent df8b5d3 commit 4eabb49
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 174 deletions.
95 changes: 0 additions & 95 deletions source/Kagi/JsonEnumMemberEnumConverter.cs

This file was deleted.

16 changes: 7 additions & 9 deletions source/Kagi/KagiSummaryEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Runtime;
using System.Runtime.Serialization;

namespace Kagi
{
/// <summary>
/// Enumerates the provided summarization engines.
/// </summary>
[JsonConverter(
typeof(JsonEnumMemberEnumConverter<KagiSummaryEngine>))]
typeof(JsonStringEnumConverter<KagiSummaryEngine>))]
public enum KagiSummaryEngine
{
/// <summary>
/// Provides a friendly, descriptive, fast summary.
/// </summary>
[EnumMember(
Value = "cecil")]
[JsonStringEnumMemberName(
"cecil")]
Cecil,

/// <summary>
/// Provides a formal, technical, analytical summary.
/// </summary>
[EnumMember(
Value = "agnes")]
[JsonStringEnumMemberName(
"agnes")]
Agnes,

/// <summary>
/// Provides a best-in-class summary using Kagi's enterprise-grade model.
/// </summary>
[EnumMember(
Value = "muriel")]
[JsonStringEnumMemberName(
"muriel")]
Muriel,
}
}
12 changes: 5 additions & 7 deletions source/Kagi/KagiSummaryKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,28 @@
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Runtime;
using System.Runtime.Serialization;

namespace Kagi
{
/// <summary>
/// Enumerates the different kinds of summarization.
/// </summary>
[JsonConverter(
typeof(JsonEnumMemberEnumConverter<KagiSummaryKind>))]
typeof(JsonStringEnumConverter<KagiSummaryKind>))]
public enum KagiSummaryKind
{
/// <summary>
/// A paragraph or more of summary prose.
/// </summary>
[EnumMember(
Value = "summary")]
[JsonStringEnumMemberName(
"summary")]
Summary,

/// <summary>
/// A bulleted list of key points.
/// </summary>
[EnumMember(
Value = "takeaway")]
[JsonStringEnumMemberName(
"takeaway")]
Takeaway,
}
}
Loading

0 comments on commit 4eabb49

Please sign in to comment.