Skip to content

Commit d32ac06

Browse files
Added hasComments flag:
This will remove the /** */ empty comments in generated files
1 parent 58ea5da commit d32ac06

File tree

8 files changed

+27
-4
lines changed

8 files changed

+27
-4
lines changed

src/models/api.model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export class ApiModel implements PhysycalFile {
4747
this._operationId = camel(operation);
4848
}
4949

50+
get hasComments(): boolean {
51+
return !!this.description || !!this.example || !!this.deprecated;
52+
}
53+
5054
get queryParamsType(): string {
5155
return this.queryParams?.type;
5256
}

src/models/entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface PhysycalFile {
22
name: string;
33
fileName: string;
4+
hasComments: boolean;
45
}

src/models/enum.model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export class EnumModel<T = string> implements PhysycalFile {
3333
return `#/components/schemas/${this.name}`;
3434
}
3535

36+
get hasComments(): boolean {
37+
return !!this.description || !!this.example || !!this.deprecated;
38+
}
39+
3640
get values(): T[] {
3741
return this._values;
3842
}

src/models/model-attributes.model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export class ModelAttributessModel {
2020
this._typeURI = typeURI;
2121
}
2222

23+
get hasComments(): boolean {
24+
return !!this.description || !!this.example || !!this.deprecated;
25+
}
26+
2327
/**
2428
* Return the type parsed, (class or primitive)
2529
*/

src/models/model.model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export class ModelModel implements PhysycalFile {
2727
return this._attributes;
2828
}
2929

30+
get hasComments(): boolean {
31+
return !!this.description || !!this.example || !!this.deprecated;
32+
}
33+
3034
getDependences(store: ModelStore): PhysycalFile[] {
3135
const dependences = new Set<PhysycalFile>();
3236

templates/api.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export class {{groupName}}Service {
2828
) {
2929
}
3030

31-
{{#apis}}
31+
{{#apis}}
32+
{{#hasComments}}
3233
/**
3334
{{#description}}
3435
* {{description}}
@@ -40,6 +41,7 @@ export class {{groupName}}Service {
4041
* @deprecated
4142
{{/deprecated}}
4243
*/
44+
{{/hasComments}}
4345
{{!
4446
// Will add options and requestBody if necessary
4547
// If both, will add comma between
@@ -57,5 +59,5 @@ export class {{groupName}}Service {
5759
);
5860
}
5961

60-
{{/apis}}
62+
{{/apis}}
6163
}

templates/enumModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{#model}}
2+
{{#hasComments}}
23
/**
34
{{#description}}
45
* {{description}}
@@ -10,6 +11,7 @@
1011
* @deprecated
1112
{{/deprecated}}
1213
*/
14+
{{/hasComments}}
1315
export enum {{ name }} {
1416
{{#values}}
1517
'{{.}}' = '{{.}}',

templates/model.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { {{name}} } from './{{fileName}}';
33
{{/dependences}}
44

5+
{{#hasComments}}
56
/**
67
{{#description}}
78
* {{description}}
@@ -13,11 +14,12 @@ import { {{name}} } from './{{fileName}}';
1314
* @deprecated
1415
{{/deprecated}}
1516
*/
17+
{{/hasComments}}
1618
{{#model}}
1719
export class {{ name }} {
1820

1921
{{#attributes}}
20-
{{#description}}
22+
{{#hasComments}}
2123
/**
2224
{{#description}}
2325
* {{description}}
@@ -29,7 +31,7 @@ export class {{ name }} {
2931
* @deprecated
3032
{{/deprecated}}
3133
*/
32-
{{/description}}
34+
{{/hasComments}}
3335
{{name}}{{#isOptional}}?{{/isOptional}}: {{type}}{{#isArray}}[]{{/isArray}}{{#default}} = {{default}}{{/default}};
3436

3537
{{/attributes}}

0 commit comments

Comments
 (0)