From 31860dc05d5b4d91c068ec9295803bb8579fe415 Mon Sep 17 00:00:00 2001 From: Taufiq Date: Tue, 22 Oct 2024 14:46:15 +0530 Subject: [PATCH 1/3] added props validation --- .../react-template/__transpiled/test-file.md.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/generator/test/test-templates/react-template/__transpiled/test-file.md.js b/apps/generator/test/test-templates/react-template/__transpiled/test-file.md.js index 93c5b0245..41f0e0d8b 100644 --- a/apps/generator/test/test-templates/react-template/__transpiled/test-file.md.js +++ b/apps/generator/test/test-templates/react-template/__transpiled/test-file.md.js @@ -1,4 +1,5 @@ 'use strict'; +import PropTypes from 'prop-types'; require('source-map-support/register'); const generatorReactSdk = require('@asyncapi/generator-react-sdk'); @@ -20,5 +21,16 @@ function testFile_md ({ }); } +//props validation +testFile_md.propTypes = { + params: PropTypes.shape({ + version: PropTypes.string.isRequired, + mode: PropTypes.string.isRequired, + }).isRequired, + asyncapi: PropTypes.shape({ + info: PropTypes.func.isRequired, + }).isRequired +}; + module.exports = testFile_md; //# sourceMappingURL=test-file.md.js.map From bc45cd6053f92405c1bd4face9ff45d213b2cb4e Mon Sep 17 00:00:00 2001 From: Taufiq Date: Tue, 22 Oct 2024 21:28:15 +0530 Subject: [PATCH 2/3] implemented in template folder --- .../__transpiled/test-file.md.js | 12 ------------ .../react-template/template/test-file.md.js | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/apps/generator/test/test-templates/react-template/__transpiled/test-file.md.js b/apps/generator/test/test-templates/react-template/__transpiled/test-file.md.js index 41f0e0d8b..93c5b0245 100644 --- a/apps/generator/test/test-templates/react-template/__transpiled/test-file.md.js +++ b/apps/generator/test/test-templates/react-template/__transpiled/test-file.md.js @@ -1,5 +1,4 @@ 'use strict'; -import PropTypes from 'prop-types'; require('source-map-support/register'); const generatorReactSdk = require('@asyncapi/generator-react-sdk'); @@ -21,16 +20,5 @@ function testFile_md ({ }); } -//props validation -testFile_md.propTypes = { - params: PropTypes.shape({ - version: PropTypes.string.isRequired, - mode: PropTypes.string.isRequired, - }).isRequired, - asyncapi: PropTypes.shape({ - info: PropTypes.func.isRequired, - }).isRequired -}; - module.exports = testFile_md; //# sourceMappingURL=test-file.md.js.map diff --git a/apps/generator/test/test-templates/react-template/template/test-file.md.js b/apps/generator/test/test-templates/react-template/template/test-file.md.js index a49aa77b8..c23eda11c 100644 --- a/apps/generator/test/test-templates/react-template/template/test-file.md.js +++ b/apps/generator/test/test-templates/react-template/template/test-file.md.js @@ -1,6 +1,7 @@ import { File, Text } from '@asyncapi/generator-react-sdk'; +import PropTypes from 'prop-types'; -export default function({ asyncapi, params }) { +const TestFile = ({ asyncapi, params }) => { return ( This is a markdown file for my application. @@ -8,4 +9,17 @@ export default function({ asyncapi, params }) { Version {params.version} running on {params.mode} mode ); -} \ No newline at end of file +} + +//props validation +TestFile.propTypes = { + params: PropTypes.shape({ + version: PropTypes.string.isRequired, + mode: PropTypes.string.isRequired, + }).isRequired, + asyncapi: PropTypes.shape({ + info: PropTypes.func.isRequired, + }).isRequired +}; + +export default TestFile \ No newline at end of file From 1909a77b766b88a6cfa9d30acf2faa876034c145 Mon Sep 17 00:00:00 2001 From: Taufiq Date: Wed, 23 Oct 2024 00:48:32 +0530 Subject: [PATCH 3/3] using function keyword --- .../test/test-templates/react-template/template/test-file.md.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/generator/test/test-templates/react-template/template/test-file.md.js b/apps/generator/test/test-templates/react-template/template/test-file.md.js index c23eda11c..2549c7e19 100644 --- a/apps/generator/test/test-templates/react-template/template/test-file.md.js +++ b/apps/generator/test/test-templates/react-template/template/test-file.md.js @@ -1,7 +1,7 @@ import { File, Text } from '@asyncapi/generator-react-sdk'; import PropTypes from 'prop-types'; -const TestFile = ({ asyncapi, params }) => { +function TestFile ({ asyncapi, params }) { return ( This is a markdown file for my application.