Skip to content

Commit

Permalink
CPPSDK: handle empty properties and propertyNames with templates (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul authored Nov 13, 2023
1 parent fcae038 commit 195bce4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions languages/javascript/templates/types/enum-empty-property.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{

}
10 changes: 7 additions & 3 deletions src/macrofier/types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 195bce4

Please sign in to comment.