Skip to content

Commit 9f388bf

Browse files
committed
feat: add descriptions to schema output
1 parent aae6306 commit 9f388bf

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const handlebarsPlugin = () => ({
3232
preventIndent: true,
3333
knownHelpersOnly: true,
3434
knownHelpers: {
35+
escapeQuotes: true,
3536
equals: true,
3637
notEquals: true,
3738
containsSpaces: true,

src/templates/partials/schemaComposition.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
type: '{{export}}',
3+
{{#if description}}
4+
description: '{{{escapeQuotes description}}}',
5+
{{/if}}
36
contains: [{{#each properties}}{{>schema}}{{#unless @last}}, {{/unless}}{{/each}}],
47
{{#if isReadOnly}}
58
isReadOnly: {{{isReadOnly}}},

src/templates/partials/schemaGeneric.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
{{#if type}}
33
type: '{{{base}}}',
44
{{/if}}
5+
{{#if description}}
6+
description: '{{{escapeQuotes description}}}',
7+
{{/if}}
58
{{#if isReadOnly}}
69
isReadOnly: {{{isReadOnly}}},
710
{{/if}}

src/templates/partials/schemaInterface.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
{{#if description}}
3+
description: '{{{escapeQuotes description}}}',
4+
{{/if}}
25
properties: {
36
{{#if properties}}
47
{{#each properties}}

src/utils/registerHandlebarHelpers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export function registerHandlebarHelpers(root: {
1010
useOptions: boolean;
1111
useUnionTypes: boolean;
1212
}): void {
13+
Handlebars.registerHelper('escapeQuotes', function (value: string): string {
14+
return value.replace(/(['"])/g, '\\$1');
15+
});
16+
1317
Handlebars.registerHelper(
1418
'equals',
1519
function (this: any, a: string, b: string, options: Handlebars.HelperOptions): string {

0 commit comments

Comments
 (0)