Skip to content

Commit

Permalink
Merge pull request #331 from dvonthenen/issue329-enum-json
Browse files Browse the repository at this point in the history
Fix Type in Warning class. Introduce Converter.
  • Loading branch information
davidvonthenen authored Sep 24, 2024
2 parents 368cafe + 5aae8c6 commit 5b3d635
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Deepgram/Models/Listen/v1/REST/Warning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,26 @@ public record Warning
/// The type of warning
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("type")]
[JsonConverter(typeof(JsonStringEnumConverter))]
public WarningType? Type { get; set; }
[JsonPropertyName("type")]
public string? Type { get; set; }

/// <summary>
/// Returns the WarningType enum value based on the Type string
/// </summary>
public WarningType WarningType
{
get
{
return Type switch
{
"unsupported_language" => WarningType.UnsupportedLanguage,
"unsupported_model" => WarningType.UnsupportedModel,
"unsupported_encoding" => WarningType.UnsupportedEncoding,
"deprecated" => WarningType.Deprecated,
_ => WarningType.UnsupportedLanguage
};
}
}

/// <summary>
/// The warning message
Expand Down

0 comments on commit 5b3d635

Please sign in to comment.