Skip to content

Commit b02837a

Browse files
committed
Updated TypeScript template
1 parent 46c5d34 commit b02837a

File tree

5 files changed

+9
-84
lines changed

5 files changed

+9
-84
lines changed

Templates/Templates.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,6 @@
246246
<Content Include="Python\Request\EntityRequestBuilder.py.tt" />
247247
<Content Include="Python\Request\Method.py.tt" />
248248
<Content Include="Python\Request\Stream.py.tt" />
249-
<Content Include="TypeScript\src\path_list.txt.tt">
250-
<Generator>TextTemplatingFileGenerator</Generator>
251-
</Content>
252249
</ItemGroup>
253250
<ItemGroup>
254251
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />

Templates/TypeScript/src/entity_types.ts.tt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616

1717
<#= writer.WriteHeader() #>
1818

19-
declare module MicrosoftGraph {
19+
2020
<# foreach(var enumType in enumTypes) { #>
21-
type <#= writer.UpperCaseFirstChar(enumType.Name) #> = <#= enumType.GetEnumValues() #>
21+
export type <#= writer.UpperCaseFirstChar(enumType.Name) #> = <#= enumType.GetEnumValues() #>
2222
<# } #>
2323
<#
2424
foreach(var entityType in entityTypes)
2525
{
2626
var methods = entityType.Methods;
2727
#>
2828

29-
interface <#= writer.UpperCaseFirstChar(entityType.Name) #><# if (entityType.Base != null) { #> extends <#= writer.UpperCaseFirstChar(entityType.Base.Name) #><# }#> {
29+
export interface <#= writer.UpperCaseFirstChar(entityType.Name) #><# if (entityType.Base != null) { #> extends <#= writer.UpperCaseFirstChar(entityType.Base.Name) #><# }#> {
3030
<# foreach(var prop in entityType.Properties.ToList()) { #>
3131
<#= prop.Name #>?: <#= prop.GetTypeString() #>
3232
<# } #>
33-
}
33+
}
3434
<#
3535
}
3636
#>
@@ -39,14 +39,9 @@ declare module MicrosoftGraph {
3939
{
4040
#>
4141

42-
interface <#= writer.UpperCaseFirstChar(complexType.Name)#> {
42+
export interface <#= writer.UpperCaseFirstChar(complexType.Name)#> {
4343
<# foreach(var prop in complexType.Properties) { #>
4444
<#= prop.Name #>?: <#= prop.GetTypeString() #>
45-
<# } #>
46-
}
4745
<# } #>
4846
}
49-
50-
declare module "MicrosoftGraph" {
51-
export = MicrosoftGraph;
52-
}
47+
<# } #>

Templates/TypeScript/src/path_list.txt.tt

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"TemplateMapping": {
33
"TypeScript": [
4-
{ "Template": "entity_types", "SubProcessor": "Other", "Name": "entity_types" },
5-
{ "Template": "path_list", "SubProcessor": "Other", "Name": "path_list" }
4+
{ "Template": "entity_types", "SubProcessor": "Other", "Name": "entity_types" }
65
]
76
}
87
}

src/GraphODataTemplateWriter/CodeHelpers/TypeScript/TypeHelperTypeScript.cs

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public static string GetTypeString(this OdcmProperty prop)
3535
switch (typeStr)
3636
{
3737
case "Stream":
38+
case "Json":
3839
typeStr = "any";
3940
break;
4041
case "Int16":
@@ -65,57 +66,7 @@ public static String UpperCaseFirstChar(String s)
6566
{
6667
return char.ToUpper(s[0]) + s.Substring(1);
6768
}
68-
69-
public static OdcmClass FindEntityByName(this IEnumerable<OdcmClass> entities, String name)
70-
{
71-
foreach (var entity in entities)
72-
{
73-
if (entity.Name.Equals(name))
74-
{
75-
return entity;
76-
}
77-
}
78-
return null;
79-
}
80-
81-
public static List<string> GetNavigationPaths(this OdcmProperty prop, string baseString, IEnumerable<OdcmClass> entities, int depth)
82-
{
83-
List<String> paths = new List<string>();
84-
if (depth > 5) return paths;
85-
OdcmClass entity = entities.FindEntityByName(prop.Type.Name);
86-
87-
string newBase;
88-
if (prop.IsCollection)
89-
{
90-
newBase = baseString + "/" + prop.Name + "/{" + prop.Type.Name + "Id}";
91-
paths.Add(baseString + "/" + prop.Name);
92-
}
93-
else
94-
{
95-
newBase = baseString + "/" + prop.Name;
96-
97-
}
98-
99-
paths.Add(newBase);
100-
if (entity.Methods.Any()) // check for actions
101-
{
102-
foreach (var method in entity.Methods)
103-
{
104-
paths.Add(newBase + "/" + method.Name);
105-
}
106-
}
107-
108-
foreach (var eprop in entity.Properties)
109-
{
110-
if (eprop.IsLink)
111-
{
112-
paths.AddRange(GetNavigationPaths(eprop, newBase, entities, depth + 1));
113-
}
114-
}
115-
116-
117-
return paths;
118-
}
69+
11970

12071
}
12172
}

0 commit comments

Comments
 (0)