diff --git a/languages/cpp/templates/types/namespace.h b/languages/cpp/templates/types/namespace.h index 626de353..b3afde8a 100644 --- a/languages/cpp/templates/types/namespace.h +++ b/languages/cpp/templates/types/namespace.h @@ -1 +1 @@ -${parent.Title}:: \ No newline at end of file +${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame} \ No newline at end of file diff --git a/src/macrofier/types.mjs b/src/macrofier/types.mjs index 8506161e..d6e53788 100644 --- a/src/macrofier/types.mjs +++ b/src/macrofier/types.mjs @@ -56,7 +56,7 @@ function getMethodSignatureParams(method, module, { destination, callback }) { const paramRequired = getTemplate('/parameters/default') const paramOptional = getTemplate('/parameters/optional') return method.params.map(param => { - let type = getSchemaType(param.schema, module, { destination }) + let type = getSchemaType(param.schema, module, { destination, namespace : true }) if (callback && allocatedPrimitiveProxies[type]) { type = allocatedPrimitiveProxies[type] } @@ -97,6 +97,7 @@ function insertSchemaMacros(content, schema, module, name, parent, property, rec .replace(/\$\{TITLE\}/g, title.toUpperCase()) .replace(/\$\{property\}/g, property) .replace(/\$\{Property\}/g, capitalize(property)) + .replace(/\$\{if\.namespace\.notsame}(.*?)\$\{end\.if\.namespace\.notsame\}/g, (module.info.title !== parent) ? '$1' : '') .replace(/\$\{parent\.title\}/g, parent) .replace(/\$\{parent\.Title\}/g, capitalize(parent)) .replace(/\$\{description\}/g, schema.description ? schema.description : '') @@ -106,10 +107,9 @@ function insertSchemaMacros(content, schema, module, name, parent, property, rec .replace(/\$\{info.title\}/g, moduleTitle) .replace(/\$\{info.Title\}/g, capitalize(moduleTitle)) .replace(/\$\{info.TITLE\}/g, moduleTitle.toUpperCase()) - // .replace(/\$\{type.link\}/g, getLinkForSchema(schema, module, { name: title })) if (recursive) { - content = content.replace(/\$\{type\}/g, getSchemaType(schema, module, { name: title, destination: state.destination, section: state.section, code: false })) + content = content.replace(/\$\{type\}/g, getSchemaType(schema, module, { name: title, destination: state.destination, section: state.section, code: false, namespace: true })) } return content } @@ -203,7 +203,7 @@ const insertObjectMacros = (content, schema, module, title, property, options) = if (schema.additionalProperties && (typeof schema.additionalProperties === 'object')) { type = schema.additionalProperties } - + if (schema.patternProperties) { Object.entries(schema.patternProperties).forEach(([pattern, schema]) => { let regex = new RegExp(pattern) @@ -591,7 +591,7 @@ function getSchemaType(schema, module, { destination, templateDir = 'types', lin if (schema.title) { union.title = schema.title } - return getSchemaType(union, module, { destination, link, title, code, asPath, baseUrl }) + return getSchemaType(union, module, { destination, link, title, code, asPath, baseUrl, namespace }) } else if (schema.oneOf || schema.anyOf) { if (!schema.anyOf) {