add DTO object generator
This commit is contained in:
@@ -9,21 +9,33 @@
|
||||
|
||||
|
||||
import { File } from '@asyncapi/generator-react-sdk';
|
||||
import { PythonGenerator, FormatHelpers } from '@asyncapi/modelina';
|
||||
|
||||
export default function ({ asyncapi, params }) {
|
||||
export default async function ({ asyncapi, params }) {
|
||||
const channels = Object.keys(asyncapi.components());
|
||||
|
||||
let content = ''
|
||||
for (const channel of channels) {
|
||||
content += `# channel: ${channel}\n`
|
||||
}
|
||||
const pythonGenerator = new PythonGenerator();
|
||||
const models = await pythonGenerator.generate(asyncapi);
|
||||
const files = [];
|
||||
for (const model of models) {
|
||||
const modelFileName = `${FormatHelpers.toPascalCase(model.modelName)}.py`;
|
||||
files.push(modelFileName);
|
||||
}
|
||||
|
||||
return (
|
||||
<File name="client2.py"># {asyncapi.info().title()}
|
||||
{`\n`}
|
||||
# {asyncapi.info().description()}
|
||||
{`\n`}
|
||||
{channels.map((ch) => `# channel: ${ch}\n`)}
|
||||
{content}
|
||||
# {channels.map((ch) => `# channel: ${ch}\n`)}
|
||||
# {content}
|
||||
# {'=========='}
|
||||
# {files}
|
||||
# {'=========='}
|
||||
</File>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user