add own includes and imports

This commit is contained in:
marys
2026-06-08 14:56:37 +02:00
parent 0b0af515be
commit bec3fcaa17
@@ -13,15 +13,15 @@ function generateModels(model) {
const properties = model.model?.properties ?? {}; const properties = model.model?.properties ?? {};
const ownIncludes = Object.values(properties) const ownIncludes = Object.values(properties)
.filter(p => p.property.constructor.name === 'ConstrainedReferenceModel') .filter(p => p.property.constructor.name === 'ConstrainedReferenceModel')
.map(p => `from ${p.property.ref.name} import ${p.property.ref.name}`).join('\n') .map(p => `from ${p.property.ref.name} import ${p.property.ref.name}`)
const anonymousModels = Object.values(properties)
.filter(p => p.property.constructor.name === 'ConstrainedArrayModel')
.map(p => `from ${p.property.valueModel.name} import ${p.property.valueModel.name}`)
const imports = model.dependencies const imports = model.dependencies
.join('\n');
return ( return (
<File name={`${model.modelName}.py`}> <File name={`${model.modelName}.py`}>
{imports} {[...imports, ...ownIncludes, ...anonymousModels].join('\n')}
{'\n\n'}
{ownIncludes}
{'\n\n'} {'\n\n'}
{model.result} {model.result}
</File> </File>