Skip to content

Commit cd49401

Browse files
Merge pull request #170 from microsoftgraph/bug/ts/descriptions
Use description and long description annotations for TS
2 parents f3252dc + 932a921 commit cd49401

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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/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)