Skip to content

Commit 66a7a3a

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 cbd0f37 commit 66a7a3a

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
@@ -380,14 +380,20 @@ export function tsEnumMember(value: string | number, metadata: { name?: string;
380380
member = ts.factory.createEnumMember(name, ts.factory.createStringLiteral(value));
381381
}
382382

383-
if (metadata.description === undefined) {
383+
const trimmedDescription = metadata.description?.trim();
384+
if (trimmedDescription === undefined
385+
|| trimmedDescription === null
386+
|| trimmedDescription === ""
387+
) {
384388
return member;
385389
}
386390

387391
return ts.addSyntheticLeadingComment(
388392
member,
389-
ts.SyntaxKind.SingleLineCommentTrivia,
390-
" ".concat(metadata.description.trim()),
393+
ts.SyntaxKind.MultiLineCommentTrivia,
394+
`/**
395+
* @description ${trimmedDescription}
396+
*/`,
391397
true,
392398
);
393399
}

0 commit comments

Comments
 (0)