Docs: Content updation of Generate Typescript Types From JSON Schema (#19283)

This commit is contained in:
RounakDhillon 2025-01-09 10:26:23 +05:30 committed by GitHub
parent 7d05902945
commit 71b56f79f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 additions and 14 deletions

View File

@ -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.
After that, you can go to the generated `openmetadata-ui/src/main/resources/ui/src/generated/*` folder and see all generated types.
### 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
```
This script processes the staged JSON schema files and generates the corresponding TypeScript types.

View File

@ -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.
After that, you can go to the generated `openmetadata-ui/src/main/resources/ui/src/generated/*` folder and see all generated types.
### 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
```
This script processes the staged JSON schema files and generates the corresponding TypeScript types.