|
1 | 1 | <# // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. #> |
2 | 2 | <#@ template debug="true" hostspecific="true" language="C#" #> |
| 3 | +<#@ include file="utils.tt" #> |
3 | 4 | <#@ output extension="\\" #> |
4 | 5 | <# |
5 | 6 | CustomT4Host host = (CustomT4Host) Host; |
|
9 | 10 | var entityTypes = model.GetEntityTypes(); |
10 | 11 | var enumTypes = model.GetEnumTypes(); |
11 | 12 | var complexTypes = model.GetComplexTypes(); |
| 13 | + |
| 14 | + var maxLineLength = 120; |
12 | 15 | #> |
13 | | -// Type definitions for the Microsoft Graph <VERSION_STRING> |
| 16 | +// Type definitions for non-npm package microsoft-graph <VERSION_STRING> |
14 | 17 | // Project: https://github.com/microsoftgraph/msgraph-typescript-typings |
15 | 18 | // Definitions by: Microsoft Graph Team <https://github.com/microsoftgraph> |
16 | 19 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
17 | 20 | // TypeScript Version: 2.1 |
18 | 21 |
|
19 | 22 | export as namespace microsoftgraph; |
20 | 23 |
|
21 | | -<# foreach(var enumType in enumTypes) { #> |
22 | | -export type <#= enumType.Name.UpperCaseFirstChar() #> = <#= enumType.GetEnumValues() #>; |
23 | | -<# } #> |
24 | 24 | <# |
25 | | - foreach(var entityType in entityTypes) |
26 | | - { |
27 | | - var methods = entityType.Methods; |
| 25 | + foreach(var enumType in enumTypes) { |
| 26 | + var enumTypeName = enumType.Name.UpperCaseFirstChar(); |
| 27 | + var enumValues = enumType.GetEnumValues(); |
| 28 | + var exportTypeLength = "export type".Length + enumTypeName.Length + enumValues.Length + 3; |
| 29 | + if (exportTypeLength < maxLineLength) { |
| 30 | +#> |
| 31 | +export type <#= enumTypeName #> = <#= enumValues #>; |
| 32 | +<# |
| 33 | + } else { |
| 34 | +#> |
| 35 | +export type <#= enumTypeName #> =<# |
| 36 | + var enums = enumValues.Split('|'); |
| 37 | + for(var i = 0; i < enums.Length; i++) { |
| 38 | +#> |
| 39 | + |
| 40 | + | <#= enums[i].Trim() #><# |
| 41 | + } |
| 42 | +#>; |
| 43 | +<# |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + foreach(var entityType in entityTypes) { |
| 48 | + var propCount = entityType.Properties.ToList().Count; |
| 49 | + var entityTypeName = entityType.Name.UpperCaseFirstChar(); |
| 50 | + if(propCount == 0 && entityTypeName[0] == 'I') { |
| 51 | +#> |
| 52 | +// tslint:disable-next-line: interface-name no-empty-interface |
| 53 | +<# |
| 54 | + } else if (entityTypeName[0] == 'I') { |
| 55 | +#> |
| 56 | +// tslint:disable-next-line: interface-name |
| 57 | +<# |
| 58 | + } else if(propCount == 0) { |
| 59 | +#> |
| 60 | +// tslint:disable-next-line: no-empty-interface |
| 61 | +<# |
| 62 | + } |
| 63 | +#> |
| 64 | +export interface <#= entityTypeName #><# |
| 65 | + if (entityType.Base != null) { |
| 66 | +#> |
| 67 | + extends <#= entityType.Base.Name.UpperCaseFirstChar() #><# |
| 68 | + } |
| 69 | +#> {<# |
| 70 | + if(propCount == 0){ |
| 71 | +#>} |
| 72 | +<# |
| 73 | + } else { |
28 | 74 | #> |
29 | 75 |
|
30 | | -export interface <#= entityType.Name.UpperCaseFirstChar() #><# if (entityType.Base != null) { #> extends <#= entityType.Base.Name.UpperCaseFirstChar() #><# }#> { |
31 | | -<# foreach(var prop in entityType.Properties.ToList()) { #> |
32 | | - <# if (prop.LongDescription != null || prop.Description != null) { #> |
33 | | - /** <#=prop.GetSanitizedLongDescription()#> */ |
34 | | - <# } #> |
35 | | - <#= prop.Name #>?: <#= prop.GetTypeString() #>; |
36 | | -<# } #> |
| 76 | +<# |
| 77 | + foreach(var prop in entityType.Properties.ToList()) { |
| 78 | + if (prop.LongDescription != null || prop.Description != null) { |
| 79 | + List<string> multiLineDescriptions = Utils.splitString(prop.GetSanitizedLongDescription(), maxLineLength); |
| 80 | + if(multiLineDescriptions.Count() == 1) { |
| 81 | +#> |
| 82 | + // <#= multiLineDescriptions.First() #> |
| 83 | +<# |
| 84 | + } else { |
| 85 | +#> |
| 86 | + /** |
| 87 | +<# |
| 88 | + foreach(var descriptionLine in multiLineDescriptions) { |
| 89 | +#> |
| 90 | + * <#= descriptionLine #> |
| 91 | +<# |
| 92 | + } |
| 93 | +#> |
| 94 | + */ |
| 95 | +<# |
| 96 | + } |
| 97 | + } |
| 98 | +#> |
| 99 | + <#= prop.Name #>?: <#= prop.GetTypeString() #>; |
| 100 | +<# |
| 101 | + } |
| 102 | +#> |
37 | 103 | } |
38 | 104 | <# |
| 105 | + } |
39 | 106 | } |
| 107 | + |
| 108 | + foreach(var complexType in complexTypes) { |
| 109 | + var propCount = complexType.Properties.ToList().Count; |
| 110 | + var complexTypeName = complexType.Name.UpperCaseFirstChar(); |
| 111 | + if(propCount == 0 && complexTypeName[0] == 'I') { |
| 112 | +#> |
| 113 | +// tslint:disable-next-line: interface-name no-empty-interface |
| 114 | +<# |
| 115 | + } else if (complexTypeName[0] == 'I') { |
| 116 | +#> |
| 117 | +// tslint:disable-next-line: interface-name |
| 118 | +<# |
| 119 | + } else if(propCount == 0) { |
| 120 | +#> |
| 121 | +// tslint:disable-next-line: no-empty-interface |
| 122 | +<# |
| 123 | + } |
| 124 | +#> |
| 125 | +export interface <#= complexTypeName #><# |
| 126 | + if (complexType.Base != null) { |
| 127 | +#> |
| 128 | + extends <#= complexType.Base.Name.UpperCaseFirstChar() #><# |
| 129 | + } |
| 130 | +#> {<# |
| 131 | + if(propCount == 0){ |
| 132 | +#>} |
| 133 | +<# |
| 134 | + } else { |
| 135 | +#> |
| 136 | + |
| 137 | +<# |
| 138 | + foreach(var prop in complexType.Properties) { |
| 139 | + if (prop.LongDescription != null || prop.Description != null) { |
| 140 | + List<string> multiLineDescriptions = Utils.splitString(prop.GetSanitizedLongDescription(), maxLineLength); |
| 141 | + if(multiLineDescriptions.Count() == 1) { |
| 142 | +#> |
| 143 | + // <#= multiLineDescriptions.First() #> |
| 144 | +<# |
| 145 | + } else { |
40 | 146 | #> |
| 147 | + /** |
41 | 148 | <# |
42 | | - foreach(var complexType in complexTypes) |
43 | | - { |
| 149 | + foreach(var descriptionLine in multiLineDescriptions) { |
| 150 | +#> |
| 151 | + * <#= descriptionLine #> |
| 152 | +<# |
| 153 | + } |
| 154 | +#> |
| 155 | + */ |
| 156 | +<# |
| 157 | + } |
| 158 | + } |
| 159 | +#> |
| 160 | + <#= prop.Name #>?: <#= prop.GetTypeString() #>; |
| 161 | +<# |
| 162 | + } |
44 | 163 | #> |
45 | | -export interface <#= complexType.Name.UpperCaseFirstChar()#><# if (complexType.Base != null) { #> extends <#= complexType.Base.Name.UpperCaseFirstChar() #><# }#> { |
46 | | -<# foreach(var prop in complexType.Properties) { #> |
47 | | - <# if (prop.LongDescription != null || prop.Description != null) { #> |
48 | | - /** <#=prop.GetSanitizedLongDescription()#> */ |
49 | | - <# } #> |
50 | | - <#= prop.Name #>?: <#= prop.GetTypeString() #>; |
51 | | -<# } #> |
52 | 164 | } |
53 | | -<# } #> |
| 165 | +<# |
| 166 | + } |
| 167 | + } |
| 168 | +#> |
0 commit comments