Skip to content

Commit 8af9661

Browse files
authored
Merge pull request #44 from microsoftgraph/collectionResponseFix
Fix for MethodCollectionResponses having incorrect return type
2 parents aa2db60 + 8e157f3 commit 8af9661

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Templates/Android/BaseModel.template.tt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,15 @@
473473
return null;
474474
}
475475

476+
public string OdcmMethodReturnType(OdcmMethod method) {
477+
return method.ReturnType is OdcmPrimitiveType
478+
? method.ReturnType.GetTypeString() : method.ReturnType.Name.ToCheckedCase();
479+
}
480+
476481
public string CollectionPageGeneric(OdcmObject c) {
477482
if (c is OdcmMethod) {
478-
return "<" + ClassTypeName(c) + ", " + ITypeCollectionRequestBuilder(c) + ">";
483+
string returnType = OdcmMethodReturnType(c as OdcmMethod);
484+
return "<" + returnType + ", " + ITypeCollectionRequestBuilder(c) + ">";
479485
}
480486
return "<" + TypeName(c) + ", " + ITypeCollectionRequestBuilder(c) + ">";
481487
}

Templates/Android/generated/BaseMethodCollectionResponse.java.tt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ import com.google.gson.annotations.*;
1313
<#=CreateClassDef(BaseTypeCollectionResponse(c), null, "IJsonBackedObject")#>
1414

1515
@SerializedName("value")
16-
public List<<#=ClassTypeName(c)#>> value;
16+
public List<<#=OdcmMethodReturnType(c as OdcmMethod)#>> value;
1717

1818
@SerializedName("@odata.nextLink")
1919
public String nextLink;
2020

2121
<#=CreateRawJsonObject()#>
22-
<#=UpdateListPropertiesWithinSetRawObject(new [] { "value" })#>
22+
<# if ( ! ((c as OdcmMethod).ReturnType is OdcmPrimitiveType) ) { #>
23+
<#= UpdateListPropertiesWithinSetRawObject(new [] { "value" })#>
24+
<# } else { #>
25+
}
26+
<# } #>
2327
}

0 commit comments

Comments
 (0)