Skip to content

Commit 0debcc3

Browse files
Added numeric enums support
1 parent ea3dfd5 commit 0debcc3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/models/enum.model.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ export class EnumModel<T = string> implements PhysycalFile {
3434
}
3535

3636
get hasComments(): boolean {
37-
return !!this.description || !!this.example || !!this.deprecated;
37+
return !!this.description || !!this.example || !!this.deprecated;
38+
}
39+
40+
get isString(): boolean {
41+
return !this.isNumeric;
42+
}
43+
44+
get isNumeric(): boolean {
45+
return this.type === 'integer' || this.type === 'number';
3846
}
3947

4048
get values(): T[] {

templates/angular2/enumModel.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313
*/
1414
{{/hasComments}}
1515
export enum {{ name }} {
16+
{{#isNumeric}}
17+
{{#values}}
18+
{{.}},
19+
{{/values}}
20+
{{/isNumeric}}
21+
{{#isString}}
1622
{{#values}}
1723
'{{.}}' = '{{.}}',
1824
{{/values}}
25+
{{/isString}}
1926
}
2027
{{/model}}

0 commit comments

Comments
 (0)