From 77bea9e999910b2d5b8cad8d7b589b313efaefdd Mon Sep 17 00:00:00 2001 From: Hideyuki Kagami Date: Sun, 17 Sep 2023 00:19:35 +0900 Subject: [PATCH] fix jdl multi-line javadoc issue --- generators/server/support/doc.mjs | 2 +- generators/server/support/doc.spec.mts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/generators/server/support/doc.mjs b/generators/server/support/doc.mjs index b0b941868a52..442f2747bf6a 100644 --- a/generators/server/support/doc.mjs +++ b/generators/server/support/doc.mjs @@ -41,7 +41,7 @@ export const formatDocAsJavaDoc = (text, indentSize = 0) => { } text = escapeDoubleQuotes(text); const indent = ' '.repeat(indentSize); - const rows = ['/**', ...text.split('/n').map(row => ` * ${row}`), ' */'].map(row => `${indent}${row}`); + const rows = ['/**', ...text.split('\\n').map(row => ` * ${row}`), ' */'].map(row => `${indent}${row}`); return rows.join('\n'); }; diff --git a/generators/server/support/doc.spec.mts b/generators/server/support/doc.spec.mts index 7195e3aebde5..80343e77f3e4 100644 --- a/generators/server/support/doc.spec.mts +++ b/generators/server/support/doc.spec.mts @@ -25,6 +25,12 @@ describe('generator - server - support - doc', () => { expect(formatDocAsJavaDoc('Comment="KO"', 1)).toBe(' /**\n * Comment=\\"KO\\"\n */'); }); }); + describe('when passing a comment with newlines', () => { + it('formats the comment correctly with line breaks', () => { + const comment = 'This is the first line.\\nAnd this is the second.'; + expect(formatDocAsJavaDoc(comment, 1)).toBe(' /**\n * This is the first line.\n * And this is the second.\n */'); + }); + }); }); describe('formatDocAsApiDescription', () => {