Skip to content

Commit 7f29289

Browse files
feat: minor jsdoc tweaks
1 parent b9905e1 commit 7f29289

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

helpers/docComment.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const indent = (text) =>
2+
// add a star before each newline and the start of the string
3+
text.replace(/^/gm, " * ");
4+
5+
module.exports = indent;

partials/model.handlebars

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
{{#if description}}
21
/**
3-
* {{description}}
2+
* {{@key}}
3+
{{#if description}}* {{description}}{{/if~}}
4+
*
5+
{{#each properties}}
6+
* @param { {{~typeConvert this~}} } {{#if _required}}{{@key}}{{else}}[{{@key}}]{{/if}} {{#if description}} - {{description}}{{/if}}
7+
{{/each}}
48
*/
5-
{{/if}}
69
export class {{@key}} {
710

811
static propertyTypes: Array<{name: string, type: string}> = [
@@ -15,9 +18,6 @@ export class {{@key}} {
1518
];
1619

1720
{{#each properties}}
18-
{{#if description}}
19-
// {{description}}
20-
{{/if}}
2121
public {{@key}}{{#unless _required}}?{{/unless}}: {{typeConvert this}};
2222
{{/each}}
23-
}
23+
}

template/api.ts.handlebars

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import { request } from "./request";
55
import { Parameter, ParameterBuilder } from "./parameterBuilder";
66
import { deserialize, serialize } from "./serializer";
77

8-
/*
9-
{{_info.title}}
10-
{{info.description}}
11-
Version: {{info.version}}
12-
*/
13-
14-
{{#if _tag.description}}// {{_tag.description}}{{/if}}
15-
8+
/**
9+
* {{_info.title}}
10+
*
11+
{{#if info.description}}{{docComment info.description}}{{/if}}
12+
{{#if info.version}} * @version {{info.version}}{{/if}}
13+
*/
1614
export default class Api{{_tag.name}} {
1715
private config: Configuration;
1816

@@ -25,12 +23,20 @@ export default class Api{{_tag.name}} {
2523
{{#each this}}
2624
{{#ifEquals ../../_tag.name _tag.name}}
2725

28-
{{#if summary}}// {{summary}}{{/if}}
29-
{{#if description}}// {{description}}{{/if}}
30-
{{#if tags}}// tags: {{tags}}{{/if}}
26+
/**
27+
{{#if summary}}
28+
* {{summary}}
29+
*
30+
{{/if}}
31+
{{#if description}}
32+
* {{description}}
33+
*
34+
{{/if}}
35+
{{#if tags}} * @tags {{tags}}{{/if}}
3136
{{#each _sortedParameters}}
32-
// @param {{name}} {{description}}
37+
* @param { {{~typeConvert schema ../../../_options~}} } {{name}} {{description}}
3338
{{/each}}
39+
*/
3440
async {{operationId}}(
3541
{{#each _sortedParameters}}
3642
{{name}}{{#if _optional}}?{{/if}}:

template/model.ts.handlebars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{{#each components.schemas}}
22
{{> model}}
3+
34
{{/each}}
45

56
{{#each components.inlineObjects}}
67
{{> model}}
8+
79
{{/each}}
810

911
export const models: string[] = [

0 commit comments

Comments
 (0)