Skip to content

Commit

Permalink
Docs: Content updation of Generate Typescript Types From JSON Schema (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
RounakDhillon authored Jan 9, 2025
1 parent 7d05902 commit 71b56f7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
This script processes the staged JSON schema files and generates the corresponding TypeScript types.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
This script processes the staged JSON schema files and generates the corresponding TypeScript types.

0 comments on commit 71b56f7

Please sign in to comment.