PYTHON_DATACLASS_PRESET and PYTHON_ATTRS_PRESET interpolate renderer.defaultSelf() into a template literal without awaiting it, so the generated class body is the literal string [object Promise].
Reproduce
import { PythonGenerator, PYTHON_DATACLASS_PRESET } from '@asyncapi/modelina';
const generator = new PythonGenerator({ presets: [PYTHON_DATACLASS_PRESET] });
const output = await generator.generate({
$id: 'User', type: 'object', properties: { name: { type: 'string' } }
});
console.log(output[0].result);
Output:
from dataclasses import dataclass
@dataclass
[object Promise]
Same for PYTHON_ATTRS_PRESET.
defaultSelf() is async, so the self hook just needs to await it (the Pydantic preset already does). I'll open a PR.
PYTHON_DATACLASS_PRESETandPYTHON_ATTRS_PRESETinterpolaterenderer.defaultSelf()into a template literal without awaiting it, so the generated class body is the literal string[object Promise].Reproduce
Output:
Same for
PYTHON_ATTRS_PRESET.defaultSelf()is async, so theselfhook just needs toawaitit (the Pydantic preset already does). I'll open a PR.