add DTO object generator
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// 1
|
||||
import { File } from '@asyncapi/generator-react-sdk';
|
||||
// 2
|
||||
import { PythonGenerator, FormatHelpers } from '@asyncapi/modelina';
|
||||
|
||||
/**
|
||||
* @typedef RenderArgument
|
||||
* @type {object}
|
||||
* @property {AsyncAPIDocument} asyncapi document object received from the generator.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Render all schema models
|
||||
* @param {RenderArgument} param0
|
||||
* @returns
|
||||
*/
|
||||
// 3
|
||||
export default async function schemaRender({ asyncapi }) {
|
||||
// 4
|
||||
const pythonGenerator = new PythonGenerator();
|
||||
// 5
|
||||
const models = await pythonGenerator.generate(asyncapi);
|
||||
// 6
|
||||
const files = [];
|
||||
// 7
|
||||
for (const model of models) {
|
||||
// 8
|
||||
const modelFileName = `${FormatHelpers.toPascalCase(model.modelName)}.py`;
|
||||
// 9
|
||||
files.push(<File name={modelFileName}>{model.result}</File>);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
Reference in New Issue
Block a user