From 71b56f79f70d30299b3ebf242a7c63c7132510bd Mon Sep 17 00:00:00 2001 From: RounakDhillon <162090200+RounakDhillon@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:26:23 +0530 Subject: [PATCH] Docs: Content updation of Generate Typescript Types From JSON Schema (#19283) --- ...erate-typescript-types-from-json-schema.md | 32 +++++++++++++++---- ...erate-typescript-types-from-json-schema.md | 32 +++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/openmetadata-docs/content/v1.6.x/developers/contribute/build-code-and-run-tests/generate-typescript-types-from-json-schema.md b/openmetadata-docs/content/v1.6.x/developers/contribute/build-code-and-run-tests/generate-typescript-types-from-json-schema.md index f128988ba242..dfa81943c7ef 100644 --- a/openmetadata-docs/content/v1.6.x/developers/contribute/build-code-and-run-tests/generate-typescript-types-from-json-schema.md +++ b/openmetadata-docs/content/v1.6.x/developers/contribute/build-code-and-run-tests/generate-typescript-types-from-json-schema.md @@ -8,18 +8,36 @@ This step-by-step guide will help you to generate typescript types from JSON sch We are using [quicktype](https://quicktype.io/) to generate types from JSON Schema. -Make sure you have `quicktype` installed if not then install it using command given below from `openmetadata` root folder. +## Prerequisites -```python +Ensure you have `quicktype` installed. If not, install it using the commands below. + +## Steps to Generate TypeScript Types + +### Step 1: Install Dependencies + +Navigate to the `openmetadata-ui` directory and install dependencies: + +```bash +cd openmetadata-ui/src/main/resources/ui yarn install ``` +### Step 2: Stage Files -Now go to the UI folder openmetadata-ui/src/main/resources/ui and from there run the command given below. +Return to the root folder, add the relevant files to the staging area, and execute the following command: -```python -yarn run json2ts +```bash +changed_files=$(git diff --cached --name-only --diff-filter=ACM | grep 'openmetadata-spec/src/main/resources/json/schema/') ``` -The above command will take some time to execute and generate types. +This command identifies all staged files located in the `openmetadata-spec/src/main/resources/json/schema/` path and stores the file paths in the changed_files variable. + +### Step 3: Generate TypeScript Types + +Run the following script to generate TypeScript types for the identified JSON schema files: + +```bash +./openmetadata-ui/src/main/resources/ui/json2ts.sh $changed_files +``` -After that, you can go to the generated `openmetadata-ui/src/main/resources/ui/src/generated/*` folder and see all generated types. \ No newline at end of file +This script processes the staged JSON schema files and generates the corresponding TypeScript types. diff --git a/openmetadata-docs/content/v1.7.x-SNAPSHOT/developers/contribute/build-code-and-run-tests/generate-typescript-types-from-json-schema.md b/openmetadata-docs/content/v1.7.x-SNAPSHOT/developers/contribute/build-code-and-run-tests/generate-typescript-types-from-json-schema.md index f128988ba242..dfa81943c7ef 100644 --- a/openmetadata-docs/content/v1.7.x-SNAPSHOT/developers/contribute/build-code-and-run-tests/generate-typescript-types-from-json-schema.md +++ b/openmetadata-docs/content/v1.7.x-SNAPSHOT/developers/contribute/build-code-and-run-tests/generate-typescript-types-from-json-schema.md @@ -8,18 +8,36 @@ This step-by-step guide will help you to generate typescript types from JSON sch We are using [quicktype](https://quicktype.io/) to generate types from JSON Schema. -Make sure you have `quicktype` installed if not then install it using command given below from `openmetadata` root folder. +## Prerequisites -```python +Ensure you have `quicktype` installed. If not, install it using the commands below. + +## Steps to Generate TypeScript Types + +### Step 1: Install Dependencies + +Navigate to the `openmetadata-ui` directory and install dependencies: + +```bash +cd openmetadata-ui/src/main/resources/ui yarn install ``` +### Step 2: Stage Files -Now go to the UI folder openmetadata-ui/src/main/resources/ui and from there run the command given below. +Return to the root folder, add the relevant files to the staging area, and execute the following command: -```python -yarn run json2ts +```bash +changed_files=$(git diff --cached --name-only --diff-filter=ACM | grep 'openmetadata-spec/src/main/resources/json/schema/') ``` -The above command will take some time to execute and generate types. +This command identifies all staged files located in the `openmetadata-spec/src/main/resources/json/schema/` path and stores the file paths in the changed_files variable. + +### Step 3: Generate TypeScript Types + +Run the following script to generate TypeScript types for the identified JSON schema files: + +```bash +./openmetadata-ui/src/main/resources/ui/json2ts.sh $changed_files +``` -After that, you can go to the generated `openmetadata-ui/src/main/resources/ui/src/generated/*` folder and see all generated types. \ No newline at end of file +This script processes the staged JSON schema files and generates the corresponding TypeScript types.