From a562638b6bd8ad0785bca9434b10e9af14ccbfed Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Sun, 12 Nov 2023 08:12:27 -0500 Subject: [PATCH] CPPSDK: handle empty properties and propertyNames with templates --- .../javascript/templates/types/enum-empty-property.mjs | 3 +++ src/macrofier/types.mjs | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 languages/javascript/templates/types/enum-empty-property.mjs diff --git a/languages/javascript/templates/types/enum-empty-property.mjs b/languages/javascript/templates/types/enum-empty-property.mjs new file mode 100644 index 00000000..0db3279e --- /dev/null +++ b/languages/javascript/templates/types/enum-empty-property.mjs @@ -0,0 +1,3 @@ +{ + +} diff --git a/src/macrofier/types.mjs b/src/macrofier/types.mjs index 280b7192..ba26051c 100644 --- a/src/macrofier/types.mjs +++ b/src/macrofier/types.mjs @@ -337,9 +337,13 @@ const insertObjectMacros = (content, schema, module, title, property, options) = const regex = new RegExp("\\$\\{" + macro + "\\}", "g") content = content.replace(regex, properties.join('\n')) .replace(/\$\{level}/g, options.parentLevel > 0 ? options.parentLevel : '') - - if (!schema.properties && !schema.propertyNames && !schema.additionalProperties) { - content = !schema.additionalProperties ? getTemplate(path.join(options.templateDir, 'object-empty-property')) : '' + if (!schema.properties && !schema.additionalProperties) { + if (schema.propertyNames && schema.propertyNames.enum) { + content = getTemplate(path.join(options.templateDir, 'enum-empty-property')) + } + else { + content = getTemplate(path.join(options.templateDir, 'object-empty-property')) + } } }) return content