Skip to content

Commit 2bd6ba0

Browse files
author
Nakul Sabharwal
committed
Merge branch 'dev' of https://github.com/microsoftgraph/MSGraph-SDK-Code-Generator into extensions-generated-java-merging
2 parents c5bf2a4 + cd49401 commit 2bd6ba0

File tree

6 files changed

+55
-28
lines changed

6 files changed

+55
-28
lines changed

Templates/Java/BaseJavaModel.template.tt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ public {1} {2}{3}{4} {{";
10801080
property.Name,
10811081
propertyType,
10821082
property.Name.SanitizePropertyName(property).ToLowerFirstChar(),
1083-
ReplaceInvalidCharacters(property.LongDescription));
1083+
GetSanitizedDescription(property));
10841084
}
10851085
return sb.ToString();
10861086
}
@@ -1258,4 +1258,14 @@ public {1} {2}{3}{4} {{";
12581258
}
12591259
return null;
12601260
}
1261-
#>
1261+
1262+
/**
1263+
* Get the description from the LongDescription or Description annotation and then return the sanitized string.
1264+
*/
1265+
public string GetSanitizedDescription(OdcmProperty property)
1266+
{
1267+
var description = property.LongDescription ?? property.Description;
1268+
1269+
return ReplaceInvalidCharacters(description);
1270+
}
1271+
#>

Templates/PHP/Model/ComplexType.php.tt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ foreach(var property in complex.Properties.Where(prop => prop.Type.GetTypeString
4949
#>
5050
/**
5151
* Gets the <#=propertyName#>
52-
<# if (property.LongDescription != null) {
52+
<# if (property.LongDescription != null || property.Description != null) {
5353
#>
54-
* <#=property.LongDescription#>
54+
* <#=property.GetSanitizedLongDescription()#>
5555
<# } #>
5656
*
5757
* @return <#=property.Type.GetTypeString()#> The <#=propertyName#>
@@ -77,9 +77,9 @@ foreach(var property in complex.Properties.Where(prop => prop.Type.GetTypeString
7777

7878
/**
7979
* Sets the <#=propertyName#>
80-
<# if (property.LongDescription != null) {
80+
<# if (property.LongDescription != null || property.Description != null) {
8181
#>
82-
* <#=property.LongDescription#>
82+
* <#=property.GetSanitizedLongDescription()#>
8383
<# } #>
8484
*
8585
* @param <#=property.Type.GetTypeString()#> $val The value of the <#=propertyName#>
@@ -108,9 +108,9 @@ foreach(var property in complex.Properties.Where(prop => prop.Type.GetTypeString
108108

109109
/**
110110
* Gets the <#=propertyName#>
111-
<# if (property.LongDescription != null) {
111+
<# if (property.LongDescription != null || property.Description != null) {
112112
#>
113-
* <#=property.LongDescription#>
113+
* <#=property.GetSanitizedLongDescription()#>
114114
<# } #>
115115
*
116116
* @return <#=property.Type.GetTypeString().SanitizeEntityName().ToCheckedCase()#> The <#=propertyName#>
@@ -135,9 +135,9 @@ foreach(var property in complex.Properties.Where(prop => prop.Type.GetTypeString
135135

136136
/**
137137
* Sets the <#=propertyName#>
138-
<# if (property.LongDescription != null) {
138+
<# if (property.LongDescription != null || property.Description != null) {
139139
#>
140-
* <#=property.LongDescription#>
140+
* <#=property.GetSanitizedLongDescription()#>
141141
<# } #>
142142
*
143143
* @param <#=property.Type.GetTypeString()#> $val The value to assign to the <#=property.Name#>

Templates/PHP/Model/EntityType.php.tt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
6969

7070
/**
7171
* Gets the <#=propertyName#>
72-
<# if (property.LongDescription != null) {
72+
<# if (property.LongDescription != null || property.Description != null) {
7373
#>
74-
* <#=property.LongDescription#>
74+
* <#=property.GetSanitizedLongDescription()#>
7575
<# } #>
7676
*
7777
* @return array The <#=propertyName#>
@@ -87,9 +87,9 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
8787

8888
/**
8989
* Sets the <#=propertyName#>
90-
<# if (property.LongDescription != null) {
90+
<# if (property.LongDescription != null || property.Description != null) {
9191
#>
92-
* <#=property.LongDescription#>
92+
* <#=property.GetSanitizedLongDescription()#>
9393
<# } #>
9494
*
9595
* @param <#=property.Type.GetTypeString().SanitizeEntityName().ToCheckedCase()#> $val The <#=propertyName#>
@@ -107,9 +107,9 @@ foreach(var property in entity.Properties.Where(prop => prop.Type.GetTypeString(
107107
#>
108108
/**
109109
* Gets the <#=propertyName#>
110-
<# if (property.LongDescription != null) {
110+
<# if (property.LongDescription != null || property.Description != null) {
111111
#>
112-
* <#=property.LongDescription#>
112+
* <#=property.GetSanitizedLongDescription()#>
113113
<# } #>
114114
*
115115
* @return <#=property.Type.GetTypeString().SanitizeEntityName().ToCheckedCase()#> The <#=propertyName#>
@@ -140,9 +140,9 @@ if (property.Type.GetTypeString()[0] == '\\') { #>
140140

141141
/**
142142
* Sets the <#=propertyName#>
143-
<# if (property.LongDescription != null) {
143+
<# if (property.LongDescription != null || property.Description != null) {
144144
#>
145-
* <#=property.LongDescription#>
145+
* <#=property.GetSanitizedLongDescription()#>
146146
<# } #>
147147
*
148148
* @param <#=property.Type.GetTypeString().SanitizeEntityName().ToCheckedCase()#> $val The <#=propertyName#>
@@ -167,9 +167,9 @@ if (property.Type.GetTypeString()[0] == '\\') { #>
167167
#>
168168
/**
169169
* Gets the <#=propertyName#>
170-
<# if (property.LongDescription != null) {
170+
<# if (property.LongDescription != null || property.Description != null) {
171171
#>
172-
* <#=property.LongDescription#>
172+
* <#=property.GetSanitizedLongDescription()#>
173173
<# } #>
174174
*
175175
* @return <#=property.Type.GetTypeString()#> The <#=propertyName#>
@@ -195,9 +195,9 @@ if (property.Type.GetTypeString()[0] == '\\') { #>
195195

196196
/**
197197
* Sets the <#=propertyName#>
198-
<# if (property.LongDescription != null) {
198+
<# if (property.LongDescription != null || property.Description != null) {
199199
#>
200-
* <#=property.LongDescription#>
200+
* <#=property.GetSanitizedLongDescription()#>
201201
<# } #>
202202
*
203203
* @param <#=property.Type.GetTypeString()#> $val The <#=propertyName#>

Templates/TypeScript/src/entity_types.ts.tt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export type <#= enumType.Name.UpperCaseFirstChar() #> = <#= enumType.GetEnumValu
3030
export interface <#= entityType.Name.UpperCaseFirstChar() #><# if (entityType.Base != null) { #> extends <#= entityType.Base.Name.UpperCaseFirstChar() #><# }#> {
3131

3232
<# foreach(var prop in entityType.Properties.ToList()) { #>
33-
<# if (prop.LongDescription != null) { #>
34-
/** <#=prop.LongDescription#> */
33+
<# if (prop.LongDescription != null || prop.Description != null) { #>
34+
/** <#=prop.GetSanitizedLongDescription()#> */
3535
<# } #>
3636
<#= prop.Name #>?: <#= prop.GetTypeString() #>
3737

@@ -47,8 +47,8 @@ export interface <#= entityType.Name.UpperCaseFirstChar() #><# if (entityType.Ba
4747
export interface <#= complexType.Name.UpperCaseFirstChar()#><# if (complexType.Base != null) { #> extends <#= complexType.Base.Name.UpperCaseFirstChar() #><# }#> {
4848

4949
<# foreach(var prop in complexType.Properties) { #>
50-
<# if (prop.LongDescription != null) { #>
51-
/** <#=prop.LongDescription#> */
50+
<# if (prop.LongDescription != null || prop.Description != null) { #>
51+
/** <#=prop.GetSanitizedLongDescription()#> */
5252
<# } #>
5353
<#= prop.Name #>?: <#= prop.GetTypeString() #>
5454

src/GraphODataTemplateWriter/CodeHelpers/PHP/TypeHelperPHP.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ public static HashSet<string> ReservedNames
3737
"double",
3838
"string"
3939
};
40+
public static string GetSanitizedLongDescription(this OdcmProperty property)
41+
{
42+
var description = property.LongDescription ?? property.Description;
4043

44+
if (description != null)
45+
{
46+
return description.Replace("<", "&lt;").Replace(">", "&gt;").Replace("&", "&amp;");
47+
}
48+
return null;
49+
}
4150

4251
public static string GetTypeString(this OdcmType @type)
4352
{

src/GraphODataTemplateWriter/CodeHelpers/TypeScript/TypeHelperTypeScript.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ public static String UpperCaseFirstChar(this String s)
5959
{
6060
return char.ToUpper(s[0]) + s.Substring(1);
6161
}
62-
63-
62+
63+
public static string GetSanitizedLongDescription(this OdcmProperty property)
64+
{
65+
var description = property.LongDescription ?? property.Description;
66+
if (description != null)
67+
{
68+
return description.Replace("<", "&lt;").Replace(">", "&gt;").Replace("&", "&amp;");
69+
}
70+
return null;
71+
}
6472
}
6573
}

0 commit comments

Comments
 (0)