Skip to content

Commit

Permalink
Updted method write
Browse files Browse the repository at this point in the history
  • Loading branch information
Microsoft Graph DevX Tooling authored and Microsoft Graph DevX Tooling committed Nov 29, 2024
1 parent aba8d81 commit a5fa774
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,30 +482,31 @@ private string GetDeserializationMethodName(CodeTypeBase propType, CodeMethod me
var parseNodeMethod = string.Empty;
if (propType is CodeType currentType)
{
var collectionMethod = propType.IsArray ? "Array" : "Collection";
if (isCollection)
// parseNodeMethod = currentType.TypeDefinition switch
// {
// //CodeType codeType when codeType.TypeDefinition == null => $"getCollectionOfPrimitiveValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])",
// CodeEnum enumType => $"getCollectionOfEnumValues({enumType.Name.ToFirstCharacterUpperCase()}::class)",
// //CodeType codeType when conventions.PrimitiveTypes.Contains(codeType.Name.ToLowerInvariant()) => $"getCollectionOfPrimitiveValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])",
// _ => $"getCollectionOfPrimitiveValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])"
// };
if (currentType.TypeDefinition == null)
parseNodeMethod = currentType.TypeDefinition switch
{
parseNodeMethod = $"getCollectionOfPrimitiveValues('{CreateDiscriminatorMethodName}')";
}
else if (conventions.PrimitiveTypes.Contains(currentType.TypeDefinition.Name.ToLowerInvariant()))
{
parseNodeMethod = $"getCollectionOfPrimitiveValues('{CreateDiscriminatorMethodName}')";
}
else if (currentType.TypeDefinition is CodeEnum)
{
parseNodeMethod = $"getCollectionOfEnumValues({currentType.TypeDefinition.Name.ToFirstCharacterUpperCase()}::class)";
}
else
{
parseNodeMethod = $"getCollectionOfObjectValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])";
}
CodeType codeType when codeType.TypeDefinition == null => $"getCollectionOfPrimitiveValues()",
CodeEnum enumType => $"getCollectionOfEnumValues({enumType.Name.ToFirstCharacterUpperCase()}::class)",
// CodeType codeType when conventions.PrimitiveTypes.Contains(codeType.Name.ToLowerInvariant()) => $"getCollectionOfPrimitiveValues('{currentType.TypeDefinition.Name}')",
_ => $"getCollectionOfPrimitiveValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])"
};
// if (currentType.TypeDefinition == null)
// {
// parseNodeMethod = $"getCollectionOfPrimitiveValues()";
// }
// else if (conventions.PrimitiveTypes.Contains(currentType.TypeDefinition.Name.ToLowerInvariant()))
// {
// parseNodeMethod = $"getCollectionOfPrimitiveValues('{currentType.TypeDefinition.Name}')";
// }
// else if (currentType.TypeDefinition is CodeEnum)
// {
// parseNodeMethod = $"getCollectionOfEnumValues({currentType.TypeDefinition.Name.ToFirstCharacterUpperCase()}::class)";
// }
// else
// {
// parseNodeMethod = $"getCollectionOfObjectValues([{conventions.TranslateType(propType)}::class, '{CreateDiscriminatorMethodName}'])";
// }
else if (currentType.TypeDefinition is CodeEnum)
parseNodeMethod = $"getEnumValue({propertyType.ToFirstCharacterUpperCase()}::class)";
}
Expand Down Expand Up @@ -948,6 +949,7 @@ private void WriteFactoryMethodBodyForIntersectionModel(CodeMethod codeElement,
writer.CloseBlock(decreaseIndent: false);
}


private void WriteFactoryMethodBodyForUnionModelForDiscriminatedTypes(CodeMethod codeElement, CodeClass parentClass, LanguageWriter writer)
{
var includeElse = false;
Expand Down

0 comments on commit a5fa774

Please sign in to comment.