Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Type in Warning class. Introduce Converter. #331

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; }

davidvonthenen marked this conversation as resolved.
Show resolved Hide resolved
/// <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
};
davidvonthenen marked this conversation as resolved.
Show resolved Hide resolved
}
}

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