Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rkodev committed Nov 21, 2024
1 parent 1fae65b commit 87f97ef
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void WriteRequestsMetadataConstant(CodeConstant codeElement, LanguageWri
var isStream = conventions.StreamTypeName.Equals(returnType, StringComparison.OrdinalIgnoreCase);
var isEnum = executorMethod.ReturnType is CodeType codeType && codeType.TypeDefinition is CodeEnum;
var returnTypeWithoutCollectionSymbol = GetReturnTypeWithoutCollectionSymbol(executorMethod, returnType);
var isPrimitive = IsPrimitiveType(returnTypeWithoutCollectionSymbol);
var isPrimitive = IsPrimitiveType(returnTypeWithoutCollectionSymbol) || IsKiotaPrimitive(returnTypeWithoutCollectionSymbol);
var isPrimitiveAlias = GetPrimitiveAlias(returnTypeWithoutCollectionSymbol) is not null;
writer.StartBlock($"{executorMethod.Name.ToFirstCharacterLowerCase()}: {{");
var urlTemplateValue = executorMethod.HasUrlTemplateOverride ? $"\"{executorMethod.UrlTemplateOverride}\"" : uriTemplateConstant.Name.ToFirstCharacterUpperCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,16 @@ TYPE_NUMBER or
TYPE_LOWERCASE_STRING or
TYPE_BYTE_ARRAY or
TYPE_LOWERCASE_BOOLEAN or
TYPE_LOWERCASE_VOID or
TYPE_LOWERCASE_VOID => true,
_ => false,
};
}

// Types that are imported from kiota-abstractions and considered as primitive types
public static bool IsKiotaPrimitive(string typeName)
{
return typeName switch
{
TYPE_DATE_ONLY or
TYPE_TIME_ONLY or
TYPE_DURATION => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,23 @@ public async Task WritesConstructorWithEnumValueAsync()
{
Name = "pictureSize"
}).First();

codeEnum.AddOption(
new CodeEnumOption
{
Name = "256x256",
SerializationName = "256x256"
},
new CodeEnumOption
{
Name = "512x512",
SerializationName = "512x512"
},
new CodeEnumOption
{
Name = "1024x1024",
SerializationName = "1024x1024"
});
parentClass.AddProperty(new CodeProperty
{
Name = propName,
Expand Down

0 comments on commit 87f97ef

Please sign in to comment.