Skip to content

Commit f13a205

Browse files
Model templating improvements
1 parent 0e33fea commit f13a205

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/models/model-attributes.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class ModelAttributessModel {
5555
* Return a fake array with "arrayLevels" elements to print it in mustache.js
5656
*/
5757
get arrayLevelsRepeater(): any[] {
58+
if (!this.arrayLevels) return null;
5859
return new Array(this.arrayLevels).fill(true);
5960
}
6061

templates/Readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,22 @@ This file implement `TemplateConfigI` interface (`src/models/template-config.mod
6565

6666
### api.?
6767

68+
> Main model file: [models/api.model.ts](../src/models/api.model.ts)
69+
6870
File used as template to generate each `Api` class.
6971

7072
An API class is composed by some `endpoints` which share the `same 1rst "tag"`.
7173

7274
### model.?
7375

76+
> Main model file: [models/model.model.ts](../src/models/model.model.ts)
77+
7478
File used to generate `each model`.
7579

7680
It's exported in a shared folder with all models.
7781

7882
### enumModel.?
7983

84+
> Main model file: [models/enum.model.ts](../src/models/enum.model.ts)
85+
8086
Same as `model` but for `enums`.

templates/angular2/model.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { {{name}} } from './{{fileName}}';
1818
{{#model}}
1919
export class {{ name }} {
2020

21-
{{#attributes}}
21+
{{#attributes}}
2222
{{#hasComments}}
2323
/**
2424
{{#description}}
@@ -32,10 +32,13 @@ export class {{ name }} {
3232
{{/deprecated}}
3333
*/
3434
{{/hasComments}}
35-
{{name}}{{#isOptional}}?{{/isOptional}}: {{type}}{{#isArray
36-
}}{{#arrayLevelsRepeater}}[]{{/arrayLevelsRepeater}}{{
37-
/isArray}}{{#default}} = {{default}}{{/default}};
35+
{{name}}{{
36+
#isOptional}}?{{/isOptional
37+
}}: {{type}}{{
38+
#arrayLevelsRepeater}}[]{{/arrayLevelsRepeater
39+
}}{{#default}} = {{default}}{{/default
40+
}};
3841

39-
{{/attributes}}
42+
{{/attributes}}
4043
}
4144
{{/model}}

0 commit comments

Comments
 (0)