Skip to content

Commit f280b1a

Browse files
committed
- adds alternate names for java json deserilization when service replies with wrong casing
1 parent 145a642 commit f280b1a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/GraphODataTemplateWriter/CodeHelpers/Java/TypeHelperJava.cs

+11-9
Original file line numberDiff line numberDiff line change
@@ -1269,9 +1269,9 @@ public static string CreateParameterDef(IEnumerable<OdcmParameter> parameters)
12691269
* The {0}.
12701270
* {1}
12711271
*/
1272-
@SerializedName(""{2}"")
1272+
@SerializedName(value = ""{2}"", alternate = {{""{3}""}})
12731273
@Expose
1274-
public {3} {4};
1274+
public {4} {5};
12751275
12761276
";
12771277
foreach (var p in parameters)
@@ -1281,6 +1281,7 @@ public static string CreateParameterDef(IEnumerable<OdcmParameter> parameters)
12811281
p.ParamName().SplitCamelCase(),
12821282
ReplaceInvalidCharacters(p.LongDescription),
12831283
p.ParamName(),
1284+
p.ParamName().ToUpperFirstChar(),
12841285
p.ParamType(),
12851286
p.ParamName().SanitizePropertyName(p).ToLowerFirstChar()
12861287
);
@@ -1413,19 +1414,19 @@ public static string CreatePropertyDef(IEnumerable<OdcmProperty> properties, boo
14131414
var format =
14141415
@" /**
14151416
* The {0}.
1416-
* {4}
1417+
* {1}
14171418
*/
1418-
@SerializedName(""{1}"")
1419+
@SerializedName(value = ""{2}"", alternate = {{""{3}""}})
14191420
@Expose
1420-
public {2} {3};
1421+
public {4} {5};
14211422
14221423
";
14231424
var collectionFormat =
14241425
@" /**
14251426
* The {0}.
1426-
* {4}
1427+
* {1}
14271428
*/
1428-
public {2} {3};
1429+
public {4} {5};
14291430
14301431
";
14311432

@@ -1454,10 +1455,11 @@ public static string CreatePropertyDef(IEnumerable<OdcmProperty> properties, boo
14541455

14551456
sb.AppendFormat(propertyFormat,
14561457
propertyName.SplitCamelCase(),
1458+
GetSanitizedDescription(property),
14571459
property.Name,
1460+
propertyName,
14581461
propertyType,
1459-
property.Name.ToLowerFirstChar().SanitizePropertyName(property),
1460-
GetSanitizedDescription(property));
1462+
property.Name.ToLowerFirstChar().SanitizePropertyName(property));
14611463
}
14621464
return sb.ToString();
14631465
}

0 commit comments

Comments
 (0)