Skip to content

Commit 3b51eb4

Browse files
authored
feat: add title in comment (#75)
1 parent 1e807f8 commit 3b51eb4

File tree

3 files changed

+1936
-12
lines changed

3 files changed

+1936
-12
lines changed

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"test:jest": "jest -c ./jest.config.js",
5454
"test:snapshot": "jest -c ./jest.snapshot.config.js",
5555
"ts": "ts-node -P tsconfig.build.json",
56-
"update:snapshot": "pnpm test:snapshot --updateSnapshot",
56+
"update:snapshot": "pnpm jest -c ./jest.snapshot.config.js --updateSnapshot",
5757
"watch": "pnpm ts ./scripts/watch.ts",
5858
"validate": "pnpm ts ./scripts/validate.ts"
5959
},
@@ -105,9 +105,6 @@
105105
"typescript": "4.2.3",
106106
"yarn-deduplicate": "3.1.0"
107107
},
108-
"peerDependencies": {
109-
"typescript": "4.2.3"
110-
},
111108
"engines": {
112109
"pnpm": ">=6"
113110
},

src/internal/OpenApiTools/components/Schema.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const generatePropertySignatures = (
2727
return factory.PropertySignature.create({
2828
name: convertContext.escapePropertySignatureName(propertyName),
2929
optional: !required.includes(propertyName),
30-
comment: schema.description,
30+
comment: [schema.title, schema.description].filter(v => !!v).join("\n\n"),
3131
type: factory.TypeNode.create({
3232
type: "any",
3333
}),
@@ -37,7 +37,7 @@ export const generatePropertySignatures = (
3737
name: convertContext.escapePropertySignatureName(propertyName),
3838
optional: !required.includes(propertyName),
3939
type: ToTypeNode.convert(entryPoint, currentPoint, factory, property, context, convertContext, { parent: schema }),
40-
comment: typeof property !== "boolean" ? property.description : undefined,
40+
comment: typeof property !== "boolean" ? [property.title, property.description].filter(v => !!v).join("\n\n") : undefined,
4141
});
4242
});
4343
};
@@ -86,7 +86,7 @@ export const generateArrayTypeAlias = (
8686
return factory.TypeAliasDeclaration.create({
8787
export: true,
8888
name: convertContext.escapeDeclarationText(name),
89-
comment: schema.description,
89+
comment: [schema.title, schema.description].filter(v => !!v).join("\n\n"),
9090
type: ToTypeNode.convert(entryPoint, currentPoint, factory, schema, context, convertContext),
9191
});
9292
};
@@ -119,7 +119,7 @@ export const generateNotInferedTypeAlias = (
119119
export: true,
120120
name: convertContext.escapeDeclarationText(name),
121121
type: typeNode,
122-
comment: schema.description,
122+
comment: [schema.title, schema.description].filter(v => !!v).join("\n\n"),
123123
});
124124
};
125125

@@ -159,11 +159,12 @@ export const generateTypeAlias = (
159159
type: schema.type,
160160
});
161161
}
162+
162163
return factory.TypeAliasDeclaration.create({
163164
export: true,
164165
name: convertContext.escapeDeclarationText(name),
165166
type,
166-
comment: schema.description,
167+
comment: [schema.title, schema.description].filter(v => !!v).join("\n\n"),
167168
});
168169
};
169170

0 commit comments

Comments
 (0)