Skip to content

Commit 800236d

Browse files
authored
Merge pull request ferdikoomen#910 from jurgenbelien/feature/description-in-schema
Add description to schema output
2 parents 1508588 + ac0d8f9 commit 800236d

File tree

6 files changed

+104
-0
lines changed

6 files changed

+104
-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+
escapeSinglequotes: 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: '{{{escapeSinglequotes 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: '{{{escapeSinglequotes 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: '{{{escapeSinglequotes 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)