Skip to content

Commit e6bdb10

Browse files
committed
Added title to models.
1 parent e62baae commit e6bdb10

File tree

8 files changed

+30
-1
lines changed

8 files changed

+30
-1
lines changed

src/client/interfaces/Model.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface Model extends Schema {
88
base: string;
99
template: string | null;
1010
link: Model | null;
11+
title: string | null;
1112
description: string | null;
1213
deprecated?: boolean;
1314
default?: string;

src/openApi/v3/parser/getModel.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const getModel = (
2222
base: 'any',
2323
template: null,
2424
link: null,
25+
title: definition.title || null,
2526
description: definition.description || null,
2627
deprecated: definition.deprecated === true,
2728
isDefinition,
@@ -62,12 +63,14 @@ export const getModel = (
6263
if (definition.enum && definition.type !== 'boolean') {
6364
const enumerators = getEnum(definition.enum);
6465
const extendedEnumerators = extendEnum(enumerators, definition);
66+
6567
if (extendedEnumerators.length) {
6668
model.export = 'enum';
6769
model.type = 'string';
6870
model.base = 'string';
6971
model.enum.push(...extendedEnumerators);
7072
model.default = getModelDefault(definition, model);
73+
7174
return model;
7275
}
7376
}

src/openApi/v3/parser/getModelProperties.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const getModelProperties = (
3636
| 'properties'
3737
> = {
3838
name: escapeName(propertyName),
39+
title: property.title || null,
3940
description: property.description || null,
4041
deprecated: property.deprecated === true,
4142
isDefinition: false,

src/templates/partials/schemaEnum.hbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,15 @@
99
{{#if isNullable}}
1010
isNullable: {{{isNullable}}},
1111
{{/if}}
12+
{{#if enum}}
13+
enums: [
14+
{{#each enum}}
15+
{
16+
name: '{{{name}}}',
17+
type: '{{{type}}}',
18+
value: {{{value}}},
19+
},
20+
{{/each}}
21+
],
22+
{{/if}}
1223
}

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: '{{{type}}}',
44
{{/if}}
5+
{{#if title}}
6+
title: `{{{escapeDescription title}}}`,
7+
{{/if}}
58
{{#if description}}
69
description: `{{{escapeDescription description}}}`,
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 title}}
3+
title: `{{{escapeDescription title}}}`,
4+
{{/if}}
25
{{#if description}}
36
description: `{{{escapeDescription description}}}`,
47
{{/if}}

src/utils/writeClientSchemas.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export const writeClientSchemas = async (
2626
indent: Indent
2727
): Promise<void> => {
2828
for (const model of models) {
29+
//console.log(model)
30+
if (model.name === 'JaxMetaType') {
31+
console.log(model)
32+
}
33+
2934
const file = resolve(outputPath, `$${model.name}.ts`);
3035
const templateResult = templates.exports.schema({
3136
...model,

src/utils/writeClientServices.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ export const writeClientServices = async (
3333
clientName?: string
3434
): Promise<void> => {
3535
for (const service of services) {
36+
/*
3637
service.operations.map(o => {
37-
console.log(o.parametersBody)
38+
console.log(o)
3839
})
40+
*/
3941
const file = resolve(outputPath, `${service.name}${postfix}.ts`);
4042
const templateResult = templates.exports.service({
4143
...service,

0 commit comments

Comments
 (0)