Skip to content

Commit 2010abd

Browse files
author
Daniel Fullmer
committed
Switch getComment to handlebars helper
1 parent 36b7352 commit 2010abd

File tree

11 files changed

+20
-16
lines changed

11 files changed

+20
-16
lines changed

rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const handlebarsPlugin = () => ({
3939
intersection: true,
4040
enumerator: true,
4141
json: true,
42+
getComment: true,
4243
},
4344
});
4445
return `export default ${templateSpec};`;

src/openApi/v2/parser/getModel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { getPattern } from '../../../utils/getPattern';
33
import type { OpenApi } from '../interfaces/OpenApi';
44
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
55
import { extendEnum } from './extendEnum';
6-
import { getComment } from './getComment';
76
import { getEnum } from './getEnum';
87
import { getEnumFromDescription } from './getEnumFromDescription';
98
import { getModelComposition } from './getModelComposition';
@@ -18,7 +17,7 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isDefiniti
1817
base: 'any',
1918
template: null,
2019
link: null,
21-
description: getComment(definition.description),
20+
description: definition.description ?? null,
2221
isDefinition,
2322
isReadOnly: definition.readOnly === true,
2423
isNullable: definition['x-nullable'] === true,

src/openApi/v3/parser/getModel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { getPattern } from '../../../utils/getPattern';
33
import type { OpenApi } from '../interfaces/OpenApi';
44
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
55
import { extendEnum } from './extendEnum';
6-
import { getComment } from './getComment';
76
import { getEnum } from './getEnum';
87
import { getEnumFromDescription } from './getEnumFromDescription';
98
import { getModelComposition } from './getModelComposition';
@@ -19,7 +18,7 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isDefiniti
1918
base: 'any',
2019
template: null,
2120
link: null,
22-
description: getComment(definition.description),
21+
description: definition.description ?? null,
2322
isDefinition,
2423
isReadOnly: definition.readOnly === true,
2524
isNullable: definition.nullable === true,

src/openApi/v3/parser/getModelProperties.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema,
2525
base: model.base,
2626
template: model.template,
2727
link: null,
28-
description: getComment(property.description),
28+
description: property.description ?? null,
2929
default: property.default,
3030
hasDefault: property.default !== undefined,
3131
isDefinition: false,
@@ -60,7 +60,7 @@ export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema,
6060
base: model.base,
6161
template: model.template,
6262
link: model.link,
63-
description: getComment(property.description),
63+
description: property.description ?? null,
6464
default: property.default,
6565
hasDefault: property.default !== undefined,
6666
isDefinition: false,

src/templates/partials/exportComposition.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{#if description}}
22
/**
3-
* {{{description}}}
3+
* {{{getComment description}}}
44
*/
55
{{/if}}
66
export type {{{name}}} = {{>type parent=name}};
@@ -12,7 +12,7 @@ export namespace {{{name}}} {
1212
{{#each enums}}
1313
{{#if description}}
1414
/**
15-
* {{{description}}}
15+
* {{{getComment description}}}
1616
*/
1717
{{/if}}
1818
export enum {{{name}}} {

src/templates/partials/exportEnum.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{{#if description}}
22
/**
3-
* {{{description}}}
3+
* {{{getComment description}}}
44
*/
55
{{/if}}
66
export enum {{{name}}} {
77
{{#each enum}}
88
{{#if description}}
99
/**
10-
* {{{description}}}
10+
* {{{getComment description}}}
1111
*/
1212
{{/if}}
1313
{{#containsSpaces name}}

src/templates/partials/exportInterface.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{{#if description}}
22
/**
3-
* {{{description}}}
3+
* {{{getComment description}}}
44
*/
55
{{/if}}
66
export type {{{name}}} = {
77
{{#each properties}}
88
{{#if description}}
99
/**
10-
* {{{description}}}
10+
* {{{getComment description}}}
1111
*/
1212
{{/if}}
1313
{{>isReadOnly}}{{{name}}}{{>isRequired}}: {{>type parent=../name}};
@@ -21,7 +21,7 @@ export namespace {{{name}}} {
2121
{{#each enums}}
2222
{{#if description}}
2323
/**
24-
* {{{description}}}
24+
* {{{getComment description}}}
2525
*/
2626
{{/if}}
2727
export enum {{{name}}} {

src/templates/partials/exportType.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{#if description}}
22
/**
3-
* {{{description}}}
3+
* {{{getComment description}}}
44
*/
55
{{/if}}
66
export type {{{name}}} = {{>type}};

src/templates/partials/parameters.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
}: {
88
{{#each parameters}}
99
{{#if description}}
10-
/** {{{description}}} **/
10+
/** {{{getComment description}}} **/
1111
{{/if}}
1212
{{{name}}}{{>isRequired}}: {{>type}},
1313
{{/each}}

src/templates/partials/typeInterface.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{#each properties}}
44
{{#if description}}
55
/**
6-
* {{{description}}}
6+
* {{{getComment description}}}
77
*/
88
{{/if}}
99
{{#if ../parent}}

0 commit comments

Comments
 (0)