Skip to content

Commit

Permalink
Fix enum default value
Browse files Browse the repository at this point in the history
  • Loading branch information
rkodev committed Nov 21, 2024
1 parent 7f4b4b6 commit 862ec49
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,13 @@ private static string GetDefaultValueLiteralForProperty(CodeProperty codePropert
propertyType.TypeDefinition is not CodeEnum enumDefinition ||
enumDefinition.CodeEnumObject is null)
{
return codeProperty.DefaultValue;
return codeProperty.DefaultValue.Trim('"').CleanupSymbolName();
}

var codeEnumOption = enumDefinition.Options.First(x =>
x.SymbolName.Equals(codeProperty.DefaultValue.Trim('"').CleanupSymbolName(),
StringComparison.OrdinalIgnoreCase));
return $"{enumDefinition.CodeEnumObject.Name.ToFirstCharacterUpperCase()}.{codeEnumOption.Name.CleanupSymbolName().ToFirstCharacterUpperCase()}";
return $"{enumDefinition.CodeEnumObject.Name.ToFirstCharacterUpperCase()}.{codeEnumOption.Name.Trim('"').CleanupSymbolName().ToFirstCharacterUpperCase()}";
}
private void WriteDefensiveStatements(CodeMethod codeElement, LanguageWriter writer)
{
Expand Down

0 comments on commit 862ec49

Please sign in to comment.