Skip to content

Commit 718653c

Browse files
Merge pull request #168 from microsoftgraph/bug/descriptions
Use both description and long description annotations
2 parents c6badfd + f81eb90 commit 718653c

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

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#>

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
{

0 commit comments

Comments
 (0)