Skip to content

Commit 6f5f226

Browse files
committed
fix: widens check condition for not appending enum description comment to nulls and empty strings too. Also using JSDoc style comment for enum description.
1 parent 68cefd2 commit 6f5f226

File tree

1 file changed

+9
-3
lines changed
  • packages/openapi-typescript/src/lib

1 file changed

+9
-3
lines changed

packages/openapi-typescript/src/lib/ts.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,20 @@ export function tsEnumMember(value: string | number, metadata: { name?: string;
388388
member = ts.factory.createEnumMember(name, ts.factory.createStringLiteral(value));
389389
}
390390

391-
if (metadata.description === undefined) {
391+
const trimmedDescription = metadata.description?.trim();
392+
if (trimmedDescription === undefined
393+
|| trimmedDescription === null
394+
|| trimmedDescription === ""
395+
) {
392396
return member;
393397
}
394398

395399
return ts.addSyntheticLeadingComment(
396400
member,
397-
ts.SyntaxKind.SingleLineCommentTrivia,
398-
" ".concat(metadata.description.trim()),
401+
ts.SyntaxKind.MultiLineCommentTrivia,
402+
`/**
403+
* @description ${trimmedDescription}
404+
*/`,
399405
true,
400406
);
401407
}

0 commit comments

Comments
 (0)